Support » Plugin: The Events Calendar » Events list won't show if main query is modified (Bug report?)

  • Resolved DaveE



    I’m trying to use The Events Calendar (v2.0.9) to display a list of events. The plugin works great (as usual), except that the main events listing/loop won’t display any entries. This is true regardless of if I’m trying to view upcoming events [~/events/upcoming/], past events [~/events/past/] or even just the main events view, if the plugin option is set that way [~/events/]. The calendar view displays just fine as do the single event pages.

    I’ve narrowed down the issue to a modification I’m making to the main query, for the blog homepage. Here’s the code I’m using:

    You’ll notice that I’m specifically making sure to only run my modifications on the main blog index (is_home) and only on the main query ($query->is_main_query()). However, my action still runs when viewing the events listing page (any of the above mentioned relative links).

    I’ve narrowed down the issue to my is_home() condition in the code above. It appears as though TEC sets is_home to true when viewing any of the listing pages. With this condition set, my query modification also runs for the events listings and therefore no events show.

    All that to say, is there a specific reason TEC sets is_home to true when viewing an events listing? To me it appears to be a bug. If there is a legitimate reason for setting is_home, would you have a suggestion for a work around for my conditional query modification so that both the query mod and the events listings can work on the same site?

    Thanks for the help!

Viewing 7 replies - 1 through 7 (of 7 total)
  • I was able to setup my own work around. Basically, I added an additional conditional check to skip my query modification if the query post_type is set to tribe_events.

    See this pastebin for details:

    It’d still be nice to understand why TEC sets the is_home() condition for event listing views.


    Plugin Author Rob La Gatta


    Hi there DaveE. Thanks for the note here, and my apologies for not responding before you had to go figure this out on your own (generally we only hit this forum about 1x a week).

    Let me see if I can get Jonah from our dev team to answer your one lingering question here. While I’m marking it RESOLVED since the core issue is set, let’s see what Jonah says when he does his forum pass tomorrow. If he can point you in the right direction on that end he absolutely will.

    Thanks for your support and patience so far!

    Hey DaveE,

    I’m not able to reproduce this locally on 2.0.10. Have you updated yet and do you see the same thing in 2.0.10? Have you tried reverting to the Twenty Eleven theme to see if this changes anything? In Twenty Eleven I am not seeing is_home() being set to true on any of the list pages…

    Let me know what you find.


    Hi Jonah,

    Thanks for getting back to me. I am able to reproduce this issue on a plain-jane installation of WordPress 3.4.2 and The Events Calendar 2.0.10. Simply put, just add the following action to your theme’s function.php file and notice that any upcoming events will stop showing up on the site. (Unless, of course, your event posts happen to have a meta_key called ‘test-query’):

    function test_query( $query ) {
        if( is_home() && $query->is_main_query() ) {
    		$query->set( 'meta_key', 'test-query' );
    		$query->set( 'orderby', 'meta_value_num' );
    		$query->set( 'order', 'ASC' );
    add_action( 'pre_get_posts', 'test_query' );

    For what it’s worth, I use the debug bar and just debugging the value for is_home() right inside this function (before the if check) will output ‘true’. Hopefully that will get you started in the right direction. If you’d like, I can get you access to my test-case for the issue. It’s a one-click install of WordPress via Dreamhost, so nothing fancy or wonky with the hosting or WP instance.


    Hi DaveE,

    I just found out that we have an open ticket on this and it’s currently slated to be fixed in our 3.0 release. For now you could throw another condition in to check if you’re NOT on an events page with one of the following conditionals:

    I hope that helps!


    Cool. Glad to know that it wasn’t me and that you’ve already got a fix in the works. I appreciate the help!

    Plugin Author Rob La Gatta


    Glad to be of service, DaveE. Thanks for using The Events Calendar and please let us know if you need anything else in the future.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Events list won't show if main query is modified (Bug report?)’ is closed to new replies.