Viewing 12 replies - 1 through 12 (of 12 total)
  • I’m not sure about feeds, but for the main loop, just before the loop:

    global $wp_query;
    $args = array_merge( $wp_query->query, array( 'post_type' => array('post','event') ));
    query_posts( $args );

    The post type array should contain the name of all the post types you wish to appear.

    Note however, that as far as WordPress is considered this is just a post – so it will be displayed in the order that the event was published, not when the event occurs.

    Also, you will need to alter you theme to check (inside the loop) when the post is of post type ‘event’, so that you can format it differently (e.g. use the plug-in provided function to display dates, venue etc). Otherwise, it will be formated like the rest of your posts.

    Thread Starter leemon

    (@leemon)

    Thanks!

    Anyone know how to apply this to a Genesis framework site (Focus child theme)? I’m looking at the home.php where the Genesis Grid Loop is called, but need some help.

    I can’t believe I ever suggested to use query_posts()….

    This is the preferred method:

    add_action('pre_get_posts','eo2010_alter_main_page',5,1);
    function eo2010_alter_main_page($query){
    
          if( $query->is_main_query() && is_front_page() ){
              $query->set('post_type', array('event'));
          }
    }

    Hi, could you please tell a php newbie where exactly this code should go, if I want to add events to the post loop?

    Functions.php 🙂

    Wow, that was fast!!

    Thanks, that was my first thought. It displays events but also kicked out my theme sidebar and reads a fatal error. I’m trying to come up with a solution to show a few events, possibly separate from the recent posts on the index. What’s the possibility of the plugin having the option make events sticky??

    Similar question: Can I have multiple loops on the page and then set one loop to display only events from one event-category using WP Query?

    Something like:

    <?php $tourdate = new WP_Query('taxonomy=event&post_type=event&category_name=my-date&showposts=1'); while ($tourdate->have_posts()) : $tourdate->the_post(); ?>

    or is that not possible?

    @jcnapw – see sgreve’s post 🙂

    @sgreve – you can have as as many loops as you like :). Your example should work, with the exception of the taxonomy query. Try this instead (there maybe syntax errors..):

    $events_query=array(
        tax_query' => array(
    		array(
    			'taxonomy' => 'event-category',
    			'field' => 'slug',
    			'terms' => 'my-term'
    		)
    	),
         'post_type' => 'event',
         'posts_per_page'=>1.
    )
    
    $tourdate = new WP_Query($events_query);
    while ($tourdate->have_posts()) : $tourdate->the_post(); ?>

    I’m trying to use the archive-event.php loop in a custom page template, but it’s just not picking up the posts for me. (My theme is laid out quite differently from Twenty Ten, so when I activate template pages the loop works but the page is scrambled.) I must be missing something – so what else is necessary other than what is between <?php /* Start the Loop */ ?> and <!----The Loop ends--> in archive-event.php?

    Thread Starter leemon

    (@leemon)

    Thanks, Stephen Harris

    @leemon – no worries!

    @jcnapw – in your case I’d recommend enabling templates, moving the plug-in provided templates to your theme and editing them there so it fits with your theme. See this page: http://www.harriswebsolutions.co.uk/event-organiser/documentation/editing-the-templates/

    If you do want to create a custom page template, then you’ll need to something similar to my previous post:

    $events_query = array(...);//Set event query
    $myevents = new WP_Query($events_query);
    if( $myevents->have_posts() ):
      while ($myevents->have_posts()) : $myevents->the_post();
       //Display content here
      endwhile;
    endif;
    wp_reset_postdata();

    As the ‘main loop’ refers to the query for the page itself, not the events.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: Event Organiser] Add events to main loop and feed’ is closed to new replies.