How do Categories work when adding Events to main blog loop

Home Forums Calendar Products Events Calendar PRO How do Categories work when adding Events to main blog loop

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1630336
    kshykula
    Participant

    Re the post: Advanced Options for Adding Events to the Main Blog Loop.

    Sorry but I cannot find this answer in the themer’s guide or knowledgebase.

    If I combine my posts and events in the main blog loop and then want to create RSS feeds based on multiple categories from the blog loop, how will that work?

    For example, in Posts, I can enter the following as my RSS url: http://www.example.com/?cat=42,43&feed=rss2

    Can I still do this once Events are merged? My event and Post categories are identical by design.

    Will my events even be picked up by the feed?

    Thanks!

    Kat

    #1632017
    Brendan
    Keymaster

    Hi there,

    Thanks for emailing support.

    Since events are custom post type, they are not added to the main RSS feed.

    You would need to add the events to RSS feed by adding a function to your functions.php file.

    The guide I included also explains how you can add additional information into RSS like the start and end times of an event.

    Once you tell WordPress to include them, they should work like your normal feed example URL.

    Let me know how that goes.

    Thanks,
    Brendan

    #1632181
    kshykula
    Participant

    Thank you. So I understand that once I combine events and posts, I can create an RSS feed containing both combined.

    But the questions remain:
    1. What if I then want to create RSS feeds containing posts and events containing multiple categories?

    e.g. I want one combined post/event RSS feed to contain info from multiple Elementary campus categories and one combined post/event RSS feed to contain info from multiple Midhigh campus categories.

    Which categories get used for these combined feeds – posts categories? or events categories?

    When I set up categories for posts and events in the first place, I made them identical – e.g. both posts and events have a K-12 category, a school council category etc.

    I know that RSS feed events by default cannot include multiple categories. With the assistance of your help desk yesterday, I have entered the code below into the functions.php file in my child theme.

    2. I can now create event RSS feeds containing multiple categories, but do I need to remove this code when I combine posts and events for RSS?

    /* ADD CAPABILITY TO CREATE MULTIPLE CATEGORY RSS FEEDS SEPTEMBER 26, 2018 */
    add_action( ‘pre_get_posts’, function( WP_Query $query ) {
    if ( ! $query->is_feed() || ‘tribe_events’ !== $query->get( ‘post_type’ ) ) {
    return;
    }

    if ( empty( $_REQUEST[ ‘tribe_event_categories’ ] ) ) {
    return;
    }

    $categories = [];

    foreach ( (array) $_REQUEST[ ‘tribe_event_categories’ ] as $event_category_id ) {
    $event_category_id = absint( $event_category_id );

    if ( $event_category_id ) {
    $categories[] = $event_category_id;
    }
    }

    if ( empty( $categories ) ) {
    return;
    }

    $tax_query = (array) $query->get( ‘tax_query’ );
    $tax_query[] = [
    ‘taxonomy’ => ‘tribe_events_cat’,
    ‘terms’ => $categories,
    ];

    $query->set( ‘tax_query’, $tax_query );
    }, 1000 );

    I know I am asking a lot and I hope that I am explaining this clearly.

    Many thanks!

    Kat

    #1632455
    Brendan
    Keymaster

    Hi Kat,

    Yeah, what I provided will only enable support for RSS.

    The remaining customization essentially looks like a custom development task and so is outside of our stated scope of support.

    With that being said, we’d love to help point you in the right direction.

    We do need to prioritize support requests from other customers at this time but I’ll certainly flag this with the team and – although we can’t make any promises – if we have time and space to come back and help, we’ll be happy to do so.  Please let us know if you’d like to go this route so that you can be added to this queue.

    Thanks,
    Brendan

    #1645739
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘How do Categories work when adding Events to main blog loop’ is closed to new replies.