Combine query_posts() and get_posts() into single query

I am creating a site which uses normal posts for a blog and the a custom post type for events(generated by the events plugin). I have successfuly used different queries to grab both but I want to combine them into one query. Have tried various things with no luck.

Here is query for blog:

Read More
<?php $mainFeatures = array( 'numberposts' => -1, 'order'=> 'DESC', 'orderby' => 'post_date');
 $postslist = get_posts( $mainFeatures );
 foreach ($postslist as $post) :  setup_postdata($post); ?>            
      <!-- stuff from post-->
 <?php endforeach; ?>

Here is query for events:

 <?php query_posts(array('post_type'=>array(TribeEvents::POSTTYPE), 'numberposts' => -1,'order' => 'ASC')); ?>
 <?php while (have_posts()) : the_post(); ?>
      <!-- stuff from post-->
 <?php endwhile;?>

Have tried this but again only gets the events:

 <?php $tryone = query_posts(array('post_type'=>post, 'posts_per_page'=> 18)); ?>
 <?php $trytwo = query_posts(array('post_type'=>array(TribeEvents::POSTTYPE))); ?>
 <?php $all_posts = array_merge( $tryone, $trytwo ); ?>

 <?php query_posts($all_posts); ?>
 <?php while (have_posts()) : the_post(); ?>
 <p>stuff</p>
 <?php endwhile;?>

Related posts

Leave a Reply

1 comment

  1. I think you are using the wrong post_type for regular posts.

    $args = array('post_type'=>array('post', TribeEvents::POSTTYPE));  
    
    // The Query
    $the_query = new WP_Query( $args );
    
    // The Loop
    while ( $the_query->have_posts() ) :
        $the_query->the_post();
        echo '<li>' . get_the_title() . '</li>';
    endwhile;
    
    // Restore original Post Data
    wp_reset_postdata();