Reputation: 1724
I displayed all the post from all the post type in the page. Now i want to display all the latest post from all the post type. I want only one post from all the post type.
To display all the post from all post type i used the following code.
<?php query_posts(array('post_type'=>array('a','b','c'), 'posts_per_page' => 2)); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div class="issue-content">
<?php if ( has_post_thumbnail() ) { the_post_thumbnail();} ?>
<?php get_template_part( 'content-issues', 'page' ); ?>
<?php comments_template( '', true ); ?>
</div><!--issue-content-->
<?php endwhile; // end of the loop. ?>
i tried with the following code
<?php query_posts(array('post_type'=>array('a','b','c'), 'posts_per_page' => 1)); ?>
i cant get from all the post type. How can i get the latest post from all the post type.
Upvotes: 0
Views: 150
Reputation: 1
You can also use, get_posts(); function for getting all posts from every post types.
Upvotes: 0
Reputation: 14381
You should use multiple query_posts()
query_posts('post_type=a&posts_per_page=1');
query_posts('post_type=b&posts_per_page=1');
query_posts('post_type=c&posts_per_page=1');
Upvotes: 2