WordPress.org

Ready to get started?Download WordPress

Forums

The Events Calendar
[resolved] Showing your events on the home page loop in 2.0 (8 posts)

  1. Shane Pearlman
    Modern Tribe
    Plugin Author

    Posted 2 years ago #

    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;
    }

    http://wordpress.org/extend/plugins/the-events-calendar/

  2. Henry
    Member
    Posted 2 years ago #

    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.

  3. roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 2 years ago #

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

  4. cecilaki_LG
    Member
    Posted 2 years ago #

    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 http://mysite.com/calendar/

    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)

  5. roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 2 years ago #

    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 pastie.org link if needed) so I can get a dev to take a look and try to identify what's up? Thanks in advance!

  6. skharmon
    Member
    Posted 1 year ago #

    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');
    	if($post_type)
    	    $post_type = $post_type;
    	else
    	    $post_type = array('post','tribe_events','attachment');
        $query->set('post_type',$post_type);
    	return $query;
        }
    }

    you can see full discussion here

  7. mpmchugh
    Member
    Posted 1 year ago #

    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.

    Thanks,
    Michael

  8. roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic