List Events only a certain caregory

Home Forums Ticket Products Event Tickets Plus List Events only a certain caregory

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1120623
    Fred
    Participant

    Hi.

    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

    #1120641
    Nico
    Member

    Hi 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,
    Nico

    #1120663
    Fred
    Participant

    Hi. 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

    #1121347
    Nico
    Member

    Hey 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,
    Nico

    #1121504
    Fred
    Participant

    Thank you, Nico. Your support was wonderful!!

    Cheers, Fred

    #1121540
    Nico
    Member

    Stocked 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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘List Events only a certain caregory’ is closed to new replies.