Home › Forums › Calendar Products › Events Calendar PRO › filter rss feed by organizer
- This topic has 11 replies, 4 voices, and was last updated 7 years ago by Matt.
-
AuthorPosts
-
February 22, 2017 at 4:17 am #1243636MattParticipant
Hi, I am looking to filter the RSS feed by organizer, I have had support before on this matter and i was given the following code snip (see below), but i have been getting feedback that it’s not filtering, on closer inspection I can see its building the feed but not filtering by organizer, can you help?
example link: https://www.cornwall.ac.uk/events/whats-on/feed/?organizer=7 (this should return one event)
// Example URL [site url]/events/feed/?organizer=6/* Tribe, get feed by organizer ID */
function tribe_alter_feed ( $query ) {if ( !is_feed() || !tribe_is_event_query() ) return;
// set organizer if passed
if ( isset ($_REQUEST['tribe_organizer']) ) $query->set('tribe_organizer', (int)$_REQUEST['tribe_organizer']);}
add_action( 'pre_get_posts', 'tribe_alter_feed' );
February 24, 2017 at 6:01 am #1245142BarryMemberHi Matt,
I’m sorry to hear that isn’t working for you.
Based on a quick look, the snippet is looking for something like ?tribe_organizer=7 in the URL whereas in your example the URL has ?organizer=7 at the end (the tribe_ prefix is missing).
Might that explain things?
February 24, 2017 at 6:11 am #1245144MattParticipantHi Barry,
Thanks for getting back to me.
I did try replacing the parameter with tribe_organizer=7 but then I get the error: ‘ERROR: This is not a valid feed.’
here is the full url I am using: https://www.cornwall.ac.uk/events/whats-on/feed/?tribe_organizer=7February 24, 2017 at 8:54 am #1245327BarryMemberOh dear!
I can take another poke at this but can’t promise anything, I’m afraid. Even if that snippet was originally provided by one of the team, customization work is something we’re not always able to assist with — especially at times where we are dealing with high volumes of support requests.
That said, do bear with me and I’ll try to circle back to this as soon as I can ๐
February 27, 2017 at 11:49 am #1246404NicoMemberHey Matt,
Thanks for the patience while I reviewed this issue by Barry’s request. Looking into the issue I found the same notice for your default feed and the event feed too:
– https://www.cornwall.ac.uk/feed/
– https://www.cornwall.ac.uk/events/feed/Does this still happens when you remove the snippet? If that’s the case then there’s an existing issue with feeds on the site that you’ll need to resolve first. You can follow the instructions detailed in our themer’s guide.
Hope this helps,
Best,
NicoFebruary 28, 2017 at 1:09 am #1246744MattParticipantHi Nico,
you might need a bit of background to our setup we are running a WP network with a dedicated event site so the structure is currently [network-base-url][subsite][event calendar prefix]
so the url that works is https://www.cornwall.ac.uk/events/whats-on/feed/so on that url the feed seems to be working (with no filters)
Cheers
February 28, 2017 at 5:59 pm #1247314NicoMemberThanks for clarifying Matt!
Give me some time to set up a multisite install and give this a try. I coded the snippet for a single site install so it might not work on the network.
In the meantime it would be great if you could share your system information with me so I can see if the plugins are up to date in your site (I’ll test the snippet with latest version of the products).
Best,
NicoMarch 6, 2017 at 7:01 am #1249846MattParticipantThis reply is private.
March 20, 2017 at 2:03 pm #1256874NicoMemberThis reply is private.
March 21, 2017 at 1:52 am #1257146MattParticipantHi Nico,
Thanks for taking the time to look at this for me, I spent a bit of time looking into the problem and think I have cracked it! here is the updated code incase it helps anyone else:// Example URL [site url]/events/feed/?organizer=6 /* Tribe, get feed by organizer ID */ function tribe_alter_feed ( $query ) { if ( !is_feed() || !tribe_is_event_query() ) return; // set organizer if passed if ( isset ($_REQUEST['organizer']) ){ //Get original meta query $meta_query = $query->get('meta_query'); //Add organizer meta query to the original meta queries $meta_query[] = array( 'key'=>'_EventOrganizerID', 'value'=> (int)$_REQUEST['organizer'], 'compare'=>'=', ); $query->set('meta_query',$meta_query); //print_r($query); } } add_action( 'pre_get_posts', 'tribe_alter_feed' );
Thanks again.
MattMarch 21, 2017 at 8:48 am #1257299NicoMemberThanks so much for the solution Matt! You did a great job here ๐
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 ‘filter rss feed by organizer’ is closed to new replies.