Showing all events despite the 'Hide From Event Listings' being checked

Home Forums Calendar Products Events Calendar PRO Showing all events despite the 'Hide From Event Listings' being checked

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1226991
    Chad
    Participant

    Hi,

    I’m trying to show all events of a category, despite the ‘Hide From Event Listings’ being checked. I know this code works when ‘Hide From Event Listings’ is unchecked. Could somebody be able to help figure out how to make this work even when ‘Hide From Event Listings’ is checked?

    $events = tribe_get_events( array(
    									 							'eventDisplay' => 'list',
    									 							'posts_per_page' => 3,
    									 							'tax_query' => array(
    									 									array(
    									 												'taxonomy' => 'tribe_events_cat',
    									 												'field'    => 'slug',
    									 												'terms'    => $group_slug,
    									 									),
    									 							),
    									 							'meta_query'     => array(
    																	array(
    																		'key'     => '_EventHideFromUpcoming',
    																		'compare' => 'NOT EXISTS',
    																		'value' => 'yes',
    
    																	),
    																),
    									 							
    									 				) );
    #1227787
    Andras
    Keymaster

    Hey Chad,

    Thanks for reaching out!

    Although I don’t have a straight answer to you, but you need to tinker around with the second part with the meta_query array. Maybe event totally remove that, so it doesn’t even check for the ‘hide’ setting. I believe then it should show events regardless of that setting.

    Check and let me know if that solves it for ya.

    Cheers,
    Andras

    #1228318
    Chad
    Participant

    No, leaving out the meta_query and/or the tax_query array doesn’t seem to solve it. To me it looks like by default the tribe_get_events function takes the ‘Hide From Event Listings’ into consideration. I would like to show all events coming up, regardless of the ‘Hide From Event Listings’ is checked or not.

    #1228899
    Andras
    Keymaster

    Hey Chad,

    Okay, I looked up how WP Query works and did some tweaks to your code.

    I didn’t test it, but in theory it should work, or at least take you a step ahead. Here it is:

    https://gist.github.com/andrasguseo/c01c096d39c495295efc4cafcffea790

    Let me know if you make progress.

    Cheers,
    Andras

    #1228900
    Andras
    Keymaster

    This is the page where I was looking for help:

    https://codex.wordpress.org/Class_Reference/WP_Meta_Query

    A.

    #1228915
    Chad
    Participant

    Thank you for taking the time to help out, but it still doesn’t work.

    I looked in the database and when the ‘Hide From Event Listings’ is checked it creates an entry in the meta_post table as “_EventHideFromUpcoming” with a “yes”. If that is not checked than that entry doesn’t exist (it deletes it when you uncheck it again).

    Can I somehow print out the SQL Query that the plugin executes with tribe_get_events()? This way I can see what is going on and if it actually takes the meta_query in consideration.

    #1229834
    Andras
    Keymaster

    Hi Chad,

    Sorry that didn’t do it. I wasn’t sure how that value is handled in the db, thanks for checking. I tweaked the code a bit to math that. Now basically it should check if that entry is “Yes” or doesn’t exist.

    https://gist.github.com/andrasguseo/c01c096d39c495295efc4cafcffea790

    And you can use var_dump() to print out the query.

    Let me know if this helps.

    Cheers,
    Andras

    #1230006
    Chad
    Participant

    Nope, still doesn’t work.

    Its almost like the ‘meta_query’ part just gets ignored. var_dump($events) only gives me ‘array(0) { }’. I want to see the actual MySQL query so I can see what is going on on.

    Thanks!

    #1230446
    Andras
    Keymaster

    Sorry to hear that didn’t help.

    For checking the queries you can try the Query Monitor plugin for that. It is a tool we also use sometimes.

    Andras

    #1230586
    Chad
    Participant

    It would be great if the developers of this plugin would actually take the time to see if they can re-create this issue, rather than guessing based on what I’m talking about. We already know how the plugin stores the data in the database, somebody (who knows the plugin very well) needs to check if the tribe_get_events() function is taking the ‘meta_query’ array into consideration properly or not. Thats out of my area of knowledge.

    Thank you!

    #1231595
    Andras
    Keymaster

    Hi Chad,

    Thank you for your feedback!

    Per our terms and conditions we support features of the plugins and although we try to help get you started on customizations for the most part you are going to have to take it on to complete.

    Despite this I was giving you information, direction and resources as well.

    Currently we are a bit swamped and just before a maintenance release, but I’ll see if I can get someone to take a look at this. I ask for your kind patience.

    Thanks for your understanding.

    Cheers,
    Andras

    #1236524
    Andras
    Keymaster

    Hello Chad,

    Thanks for your patience!

    You could setup and tear down a filter immediately before/after the custom query, in order to stop the hide-upcoming logic from kicking in. Basic approach would be:

    function undo_hide_upcoming_logic( $query ) {
    $query->set( 'hide_upcoming', false );
    }
    
    // Setup workaround
    add_action( 'tribe_events_pre_get_posts', 'undo_hide_upcoming_logic' );
    
    // Run custom query
    $events = tribe_get_events( array( /* Custom params */ ) );
    
    // Teardown workaround
    remove_action( 'tribe_events_pre_get_posts', 'undo_hide_upcoming_logic' );

    Note that this is just an untested outline, but should give you the basic idea.

    Does this help?

    Andras

    #1251816
    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 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Showing all events despite the 'Hide From Event Listings' being checked’ is closed to new replies.