0

This question already has an answer here:

I'm trying to add a 'Lessons' post type to populate the wp-query as well as the pre-existing post type 'Modules. Preferably I would like them to be combined into one query showing the most recent 6 posts. I've only been able to get them showing in 2 different queries thus far.

<?php 
//Template Name: Last 6 Modules
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'ca_show_last_six_modules' );
function ca_show_last_six_modules(){ 
$modules = new WP_Query(array(
    'post_type'         => 'module',
   'orderby'            => 'menu_order', 
    'order'                 => 'ASC',
    'status'            => 'publish',
    'posts_per_page'    => 6

));
if ( $modules->have_posts() ) : ?>
    <div class="row">   
        <?php while ( $modules->have_posts() ) : $modules->the_post(); ?>
            <?php get_template_part( 'template-parts/modules', 'loop' ); ?>
        <?php endwhile; ?>
    </div>
<?php endif;
}
 genesis(); ?>

marked as duplicate by rudtek, Jacob Peattie, cjbj, Nathan Johnson, fuxia Jun 1 at 2:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

If you look at the wp_query documentation you will see that it is possible to pass multiple arguments as post_type. Like this:

'post_type' => array( 'module', 'lessons' )

Not the answer you're looking for? Browse other questions tagged or ask your own question.