Multiple Categories in RSS feed

Home Forums Calendar Products Events Calendar PRO Multiple Categories in RSS feed

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1628774
    kshykula
    Participant

    Hello, I followed the instructions in a support thread having the same title as the one I just created.

    my RSS URL for multiple categories is as follows:

    https://www.westmountcharter.com/?feed=rss&cat=119,242

    Only category 119 gets picked up with 242 being ignored. I have tried with this with a whole string of category numbers that I would like to include with the same result. RSS for multiple categories for a regular WordPress post works just fine.

    Could you possibly help me with the syntax? Am I missing something?

    Many thanks,

    Kat

    #1629348
    kshykula
    Participant
    #1630832
    Andras
    Keymaster

    Hi,

    Thanks for reaching out!

    For a category feed you can use this url structure:

    https://www.westmountcharter.com/events-calendar/feed/?tribe_eventcategory=133

    I’m not sure if it is possible to get more categories into the feed though. Please give me some time to check.

    Cheers,
    Andras

    #1631514
    Andras
    Keymaster

    Hi again,

    A colleague was kind enough to take a look at this and came up with the following snippet:

    [code language=”php”]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 );[/code]

    Copy it into your child theme’s functions.php file.

    The above snippet would support URLs following this sort of format:

    /events/feed/?tribe_event_categories[]=123&tribe_event_categories[]=456

    Hope this helps.

    Cheers,
    Andras

    #1632083
    kshykula
    Participant

    You guys are like MAGIC!

    Works like a charm. THANK YOU!!!!

    Kat

    #1633446
    Barry
    Member

    Happy to help, Kat 🙂

    #1646176
    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 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Multiple Categories in RSS feed’ is closed to new replies.