Including "hidden" events when doing a custom query

Home Forums Calendar Products Events Calendar PRO Including "hidden" events when doing a custom query

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1149626
    nysci
    Participant

    I’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.

    #1149830
    Cliff
    Member

    Hi.

    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.

    #1152269
    nysci
    Participant

    This 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!

    #1152401
    Cliff
    Member

    My 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.

    #1161040
    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 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Including "hidden" events when doing a custom query’ is closed to new replies.