Forum Replies Created
-
AuthorPosts
-
Sunny BainsParticipant
I haven’t been able to try this today and I’m now away for a week. Can we keep this open so I can pick it up when I get back.
I would like to know, when using remove action what global variable is assigned to the class Tribe__Events__Query?
Sunny BainsParticipantIt still didn’t work, but we don’t need them now as we’ve done something else for the pop-ups.
Sunny BainsParticipantI had reviously tried hooking one tribe_events_pre_get_posts which didn’t work. I have also now tried hooking to both but still it doesn’t work.
Is there an easy way for me to override function pre_get_posts in /the-events-calendar/src/Tribe/Query.php?
Sunny BainsParticipantDigging deeper into this, the reason it works sometimes and not if I use the next/previous links is the function ‘pre-get_posts’ in /the-events-calendar/src/Tribe/Query.php overwrites my meta_query rather than adding to it.
If I move assigning the query from functions.php to /the-events-calendar/src/Tribe/Query.php all is well.
The code I have added to Query.php at line 347 (after the block commeted as ‘hide upcoming events from query (only not in admin)’):
if ( !Tribe__Admin__Helpers::instance()->is_screen( 'edit-tribe_events' ) ) { // Filter out any cancelled events $meta_query[] = array( 'key' => get_event_custom_field_key('Event Cancelled'), 'value' => 'Yes', 'compare' => '!=', ); }
since this is a core plugin file is there any way I can override this so that upgrades will still work without breaking the changes?
- This reply was modified 7 years, 9 months ago by Sunny Bains.
Sunny BainsParticipantI found the issue with this:
In adding a custom tax query in functions.php I was excluding the filter for archive type rather than post type … all sorted now.
Sunny BainsParticipantLooking a little more into this is seems to be specificly related to the ‘Next/Previous Week/Month’ links.
If I access a calendar page by linking to the URL directly, or typing it, or by switching between the week/month views then it works fine. If get to the page using the next/previous links then the events that were excluded by ‘pre_get_posts’ are still visible UNTIL I refresh the page. Also use of the browsers back button causes the filtered events to still be visible.
If you want to see this happening I can share HTTP access details for the developemnt site to you privately.
Sunny BainsParticipantThanks, I added a little extra code to retain any existing notices (e.g. no events found) but that works a treat.
-
AuthorPosts