2012-11-19 6 views
0

페이지의 모든 게시물 유형에서 모든 게시물을 표시했습니다. 이제 모든 게시물 유형의 모든 최신 게시물을 표시하고 싶습니다. 모든 게시물 유형에서 하나의 게시물 만 원합니다.모든 게시물 유형의 최신 게시물 표시

모든 게시물 유형의 모든 게시물을 표시하려면 다음 코드를 사용하십시오.

<?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. ?> 

나는 모든 포스트 유형에서 얻을 어차피 다음 코드

<?php query_posts(array('post_type'=>array('a','b','c'), 'posts_per_page' => 1)); ?> 

로했습니다. 모든 게시물 유형에서 최신 게시물을 얻으려면 어떻게해야합니까? 당신은 모든 것들을 유형에서 모든 게시물을 받고 여러 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'); 

답변

2

.

+0

긴 방법입니다. 방법을 짧게 배열을 사용하는 어떤 방법이 있나요. – Ranjit

+1

이 웹 사이트는 다음과 같은 유용한 방법을 제공합니다. http://betterwp.net/9-latest-posts-from-each-post-type/ – RRikesh

0

또한 사용할 수 get_posts(); 기능을 사용한다

+0

get_posts 기능 사용에 대한 설명이 있습니다. http://codex.wordpress.org/Template_Tags/get_posts –

관련 문제