Home › Forums › Ticket Products › Event Tickets Plus › List Events only a certain caregory
- This topic has 6 replies, 3 voices, and was last updated 9 years, 10 months ago by
Fred.
-
AuthorPosts
-
May 31, 2016 at 7:30 am #1120623
Fred
ParticipantHi.
From the list below,
https://www.primeeducation.com.au/events/list/
Could you please let me know how to narrow the list by a category?
Cheers, Fred
May 31, 2016 at 8:07 am #1120641Nico
MemberHi there Fred,
Thanks for reaching out to us on this!
There are a couple of ways of doing this:
- Link to category: simply create a link to the category, https://www.primeeducation.com.au/events/category/category_name.
- Category colors plugin: this handy plugins adds a category navigation before the calendar, check it out!
- Filter events via snippet: if you want to limit all event views to one or more categories, just paste the snippet below into the theme’s functions.php file and be sure to input your event category slug:
/*
* Just show events from categories "meetup" and "shindig" from list and month views
*/
function tribe_exclude_events_category( $wp_query ) {
// Slugs for the categories you wish to show
$include_cats = array('meetup', 'shindig');
// Include all posts on admin views
if ( is_admin() ) return $wp_query;
// Join with current tax query if set
if (is_array($wp_query->tax_query)) {
$tax_query = $wp_query->tax_query;
} else {
$tax_query = array();
}
// Setup the tax query to include terms from the tribe_events_cat taxonomy
$tax_query[] = array(
'taxonomy' => 'tribe_events_cat',
'field' => 'slug',
'terms' => $include_cats
);
if (
tribe_is_event_query()
// && !is_single() // Uncomment to allow directly viewing an individual event page
// && !is_tax() // Uncomment to allow directly viewing the category page
) {
$wp_query->set('tax_query', $tax_query);
}
return $wp_query;
}
add_action( 'pre_get_posts', 'tribe_exclude_events_category', 100, 1 );
Please let me know if this answers your question,
Best,
NicoMay 31, 2016 at 8:37 am #1120663Fred
ParticipantHi. Nico.
Thanks for your prompt response for my query.
The first option “Link to Category” seems to be the best one for me.
I have tested to create a category called “short-course” and a event “Circle Geometry” is connected to “short-course”, but do not know hot to display (list) only the events under this category.Looking forward to hearing from you 🙂
Cheers, Fred
June 1, 2016 at 1:22 pm #1121347Nico
MemberHey Fred,
Thanks for following up! If the category name/slug is ‘short-course’ (and ‘events’ slug is not modified) the URL should be: http://site.com/events/category/short-course/.
Also, if you go to WP-Admin > Events > Event Categories you can open each one using the view link (https://cloudup.com/c0-3r8ktsc9).
Please let me know if this answers your question or if I’m missing something,
Best,
NicoJune 2, 2016 at 1:56 am #1121504Fred
ParticipantThank you, Nico. Your support was wonderful!!
Cheers, Fred
June 2, 2016 at 5:03 am #1121540Nico
MemberStocked to hear Fred, thanks!
I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.
Best,
Nico -
AuthorPosts
- The topic ‘List Events only a certain caregory’ is closed to new replies.
