• Resolved bunjip

    (@bunjip)


    Hi,

    I want to alter the standard main query when accessing an events archive page. Therefore, I included some custom code in my plugin:

    function my_alter_event_query($query){
    	if (!(is_admin()) && tribe_is_event_query() && $query->is_main_query()){
    		$query->set('eventDisplay', 'custom');
    		$query->set('start_date', '2016-10-01');
    		$query->set('end_date', '2017-02-27');
    		//var_dump($query);
    	}
    }
    add_action('pre_get_posts', 'my_alter_event_query');

    When dumping the $query object, I can see the added ‘start_date’ and ‘end_date’ query variables. However, the actual executed query in the custom template still renders the ‘default’ time range and does by no means regard the start_date and end_date values.

    For custom templating, I simply use the original templates copied to my custom theme. There hasn’t been any other issue with that yet. And I’m using the original template functions, just altered some HTML markup in the list/loop.php template.

    So, what am I missing here? Any help is much appreciated.
    Best,

    Bunjip

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Bunjip,

    Thanks for using our plugin – happy to help!

    Can you verify that this is still the case with the current version we just released? (Version 4.4.0.1) Once you confirm, we can work on this issue!

    Best,

    Shelby ??

    Thread Starter bunjip

    (@bunjip)

    Hey Shelby,

    With Version 4.4.0.1 the customized query returns the results just as expected :).

    Thanks,
    Bunjip

    Good to hear, Bunjip!

    Feel free to reach out in the future if you have questions about our plugin. ??

    Best,

    Shelby ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Query params start_date and end_date not working when using ‘pre_get_post’ hook’ is closed to new replies.