Support » Plugin: The Events Calendar » [Plugin: The Events Calendar] Showing your events on the home page loop in 2.0

  • ResolvedPlugin Author Shane Pearlman


    A lot of people have asked how to get their events to show in the main post loop now that we have moved to a custom post type.

    The good news is that John, with a little inspiration from Justin Tadlock, just emailed me the basis for a solution. I haven’t had a chance to test it so we may need to tweak this as a community, but I’m sure there are plenty of you who will help me get it figured out!

    Just add this to your theme’s functions.php to include events on the home page.

    add_filter( 'pre_get_posts', 'include_events_on_home' );
    function include_events_on_home( $query ) {
    if ( is_home() && false == $query->query_vars['suppress_filters'] )
    $query->set( 'post_type', array( 'post', 'tribe_events', 'attachment' ) );
    return $query;

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi Shane,

    I can see from the above code that the custom post type you guys have created is “tribe_events”.

    I’ve added a list of events to my sitemap.php template. Someone might find the following code useful:

    <ul><?php $event_archive_query = new WP_Query('showposts=1000&post_type=tribe_events');
    while ($event_archive_query->have_posts()) : $event_archive_query->the_post(); ?><li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li><?php endwhile; ?></ul>

    Killer plugin by the way.

    Plugin Author Rob La Gatta


    Thanks for sharing, Thirstcard! I can definitely see this being of value to other users. Most appreciated 🙂

    Hi Shane and Rob,

    I have actually tried out the above code you suggested, and I’ve noticed it causes conflict and prevents the calendar view to be displayed with the link provided in the settings page :

    Your current Events URL is

    I don’t know if it’s theme-related or not, (I have been trhough many debugging hours) but I assume so, for the moment I don’t know what to do with that, cause I really wanted to insert my Events somehow into my homepage’s loop si that they’re viewable not only with the calendar/list page, and if possible not with the widget..

    A workaround could be to widgetize my homepage but I would love to get my Events posted next to the regular posts or other articles ..

    So for the moment, no other option to include the Events into the loop ? (I’ve tried also with tags and categories but it didn’t work)

    Plugin Author Rob La Gatta


    Hey cecilaki_LG. Thanks for the note; sorry to hear you’re having problems. Would you mind sharing a link to your site, and possible the code you used (via a link if needed) so I can get a dev to take a look and try to identify what’s up? Thanks in advance!

    hey cecilaki_LG
    not sure if you ever figure this out, but Jonas Grumby posted the solution below:

    add_filter('pre_get_posts', 'query_post_type');
    function query_post_type($query) {
      if(is_category() || is_tag() || is_home() && empty( $query->query_vars['suppress_filters'] ) ) {
        $post_type = get_query_var('post_type');
    	    $post_type = $post_type;
    	    $post_type = array('post','tribe_events','attachment');
    	return $query;

    you can see full discussion here

    Is there a way to have the events show up in a particular category?

    My site isn’t using a main blog page, but rather just a couple separate blog category pages, so it’d be nice to be able to filter them into an Events category.


    Plugin Author Rob La Gatta


    Thanks for coming back and re-posting this, skharmon! We appreciate it. While Michael’s last request there might be unfortunately outside the scope of support we can provide, if you or cecilaki_LG have any ideas I’m sure he would appreciate hearing them. (Sorry I couldn’t offer up more on our end in an official capacity, Michael). I am going to mark the core issue RESOLVED, though, as it seems we’re set with that.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: The Events Calendar] Showing your events on the home page loop in 2.0’ is closed to new replies.