Home › Forums › Calendar Products › Events Calendar PRO › Multiple Categories in RSS feed
- This topic has 5 replies, 3 voices, and was last updated 5 years, 7 months ago by Barry.
-
AuthorPosts
-
September 23, 2018 at 6:30 pm #1628774kshykulaParticipant
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
September 24, 2018 at 11:20 am #1629348kshykulaParticipantCorrection:
https://www.westmountcharter.com/events-calendar/feed/ seems to work (picking up all)
https://www.westmountcharter.com/events-calendar/?feed=rss&cat=119,242 does NOT work.
Thanks!
September 26, 2018 at 1:11 am #1630832AndrasKeymasterHi,
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,
AndrasSeptember 26, 2018 at 1:10 pm #1631514AndrasKeymasterHi 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,
AndrasSeptember 27, 2018 at 7:19 am #1632083kshykulaParticipantYou guys are like MAGIC!
Works like a charm. THANK YOU!!!!
Kat
September 28, 2018 at 12:18 pm #1633446BarryMemberHappy to help, Kat 🙂
October 20, 2018 at 9:35 am #1646176Support DroidKeymasterHey 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 -
AuthorPosts
- The topic ‘Multiple Categories in RSS feed’ is closed to new replies.