Home › Forums › Calendar Products › Events Calendar PRO › Including "hidden" events when doing a custom query
- This topic has 5 replies, 4 voices, and was last updated 9 years, 8 months ago by
nysci.
-
AuthorPosts
-
August 9, 2016 at 12:24 pm #1149626
nysci
ParticipantI’m using ACF to allow a user to choose an existing event from a list. I already have a filter in there so that past as well as future events are included in the list. I did that by modifying the arguments (which I think are passed to get_posts) like so:
add_filter('acf/fields/post_object/query/name=related_events', 'ahs_include_future_events', 10, 3); function ahs_include_future_events( $args, $field, $post_id ) { $args['eventDisplay'] = 'custom'; return $args; }I also want “hidden” events (i.e. those with a checkbox checked for “Hide From Event Listings”. But I can’t figure out how to modify the $args. I tried adding:
$args['hide_upcoming'] = false;but that didn’t work. Guidance?
Thanks.
August 9, 2016 at 7:59 pm #1149830Cliff
MemberHi.
hide_upcoming is referring to upcoming events — i.e. events in the future.
I’m not sure if this is what you’re needing, but it may help:
If you’re referring to this checkbox, it creates a boolean value for the _EventHideFromUpcoming meta key, so you could use tribe_get_events() — additional reference — along with https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
Please let me know if this helped.
August 16, 2016 at 12:29 pm #1152269nysci
ParticipantThis seems like it should work, but it still doesn’t.
// Show hidden events in lists for choosing grid boxes add_filter('acf/fields/post_object/query/name=event', 'ahs_include_hidden_events', 10, 3); function ahs_include_hidden_events( $args, $field, $post_id ) { $args['meta_query'] = array( array( 'key' => '_EventHideFromUpcoming', 'compare' => 'NOT EXISTS', ), ); return $args; }I also tried meat_value of ‘yes’ and compare of “NOT LIKE”, but that also didn’t work. (It took some research into the database to find out that it doesn’t save a boolean value; it saves the word “yes”. You might want to make a note of that!)
It’s possible that this has to do with ACF, and not with tribe_events. I’d be grateful for any other ideas you have, though!
August 16, 2016 at 7:39 pm #1152401Cliff
MemberMy apologies for that mistake about boolean. You are correct that the value of _EventHideFromUpcoming is a “yes” string if that box is checked.
While I can’t help with your code overall, your NOT EXISTS is probably working correctly, since _EventHideFromUpcoming actually does exist for all events. So you should check that it != ” or that it !=”yes”
I hope that gets you over the finish line for this. Let me know.
September 7, 2016 at 9:35 am #1161040Support Droid
KeymasterHey 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 ‘Including "hidden" events when doing a custom query’ is closed to new replies.
