This tutorial will assume that you had already registered your custom post type. In this tutorial I will show you how to display recent posts from a single or multiple post types.

I will not mention many methods here as methods of displaying recent posts are already mentioned in my previous tutorial. You can apply or use those methods here as we will only change the arguments of the query while the methods stays the same.

Single Post Type

Lets use WP_Query to get the list of posts from the database. By adding the post_type argument, we can grab posts from specific post type.

<?php
$args = array(
			'post_type' => 'news',
			'posts_per_page' => '5',
			'orderby' => 'date',
			'order' => 'DESC'
		);
$query = new WP_Query($args);
if($query->have_posts()) : ?>
    <ul>
        <?php while($query->have_posts()) : $query->the_post(); ?>
            <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
        <?php endwhile; wp_reset_postdata(); ?>
    </ul>
<?php endif; ?>

The example above will get the 5 recent posts from the news post type.

Multiple Post Types

There is no special here. By using the same argument but supplying the value with an array of post types, we can grab posts from the specified post types.

<?php
$args = array(
			'post_type' => array('events', 'post', 'news'),
			'posts_per_page' => '10',
			'orderby' => 'date',
			'order' => 'DESC'
		);
$query = new WP_Query($args);
if($query->have_posts()) : ?>
    <ul>
        <?php while($query->have_posts()) : $query->the_post(); ?>
            <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
        <?php endwhile; wp_reset_postdata(); ?>
    </ul>
<?php endif; ?>

The example above will get the 10 recent posts from post, news, and event post types.