2015-01-15 2 views
2

나는 내 코드에서 첫 번째 쿼리에 표시된 게시물을 제거하고 위의 3 개의 최근 게시물을 표시하는 방법을 원합니다.WordPress 최근 게시물에서 게시물을 제거

최고 게시물 :

<?php query_posts('posts_per_page=1'); if (have_posts()) : while (have_posts()) : the_post();?> 
<h2><?php the_title(); ?></h2> 
<div class="news-feat-img"> 
<a href="<?php the_permalink(); ?>" ><?php the_post_thumbnail('indexsavedimage'); ?></a> 
</div> 
<?php the_excerpt(); ?> 
<?php endwhile; endif; wp_reset_query();?> 

최근 포스트 :

</a><div class="clearboth"></div> 
<div class="borderline"></div> 
<?php query_posts('posts_per_page=3'); if (have_posts()) : while (have_posts()) : the_post();?> 
<!-- Older news articles --> 
<div class="news-posts"> 
<div class="news-thumb-wrap"> 
<div class="news-thumb"> 
<a href="<?php the_permalink(); ?>" ><?php the_post_thumbnail('newsimages'); ?></a> 
</div> 
</div> 
<!-- Truncate long titles to stop the layout from messing up! --> 
<a class="title" href="<?php the_permalink(); ?>"> 
<strong><?php the_title(); ?></strong> 
</a> 
<div class="clearboth"></div> 
<?php the_excerpt(); ?> 
<div class="news-action"> 
<span class="label"><?php the_category(', '); ?></span> 
<a href="<?php the_permalink(); ?>" ><span class="label"><i class="icon-share icon-white"></i> </span></a> 
</div> 
</div> 
<?php endwhile; endif; wp_reset_query();?> 

enter image description here

+0

그래서 첫 번째 최고 게시물 (3)을 가져 와서 첫 번째 특정 스타일을 다른 스타일로 다시 표시하고 싶습니까? 죄송합니다, 잘못 읽었습니다. – phatskat

+0

@phatskat 매우 큰 윗부분이 보이며 하단에도 표시됩니까? 그 게시물을 하단에서 제거하고 그 게시물 다음에 최근 게시물 3 개를 대신 표시하고 싶습니다. –

답변

0

첫째, 당신이하지 않은 당신의 인수를 준비하는 경우 WP_Query에 읽어 - http://codex.wordpress.org/Class_Reference/WP_Query

중요한 인수는 posts_per_page

<?php 
$posts = WP_Query(array(
    'posts_per_page' => 4, 
    # ... 
)); 

# From WordPress's example, modified of course 
$i = 0; 
if ($the_query->have_posts()) { 
     while ($the_query->have_posts()) { 
       $the_query->the_post(); 

       if(!$i) 
       { 
        // First style 
        echo "Some HTML for the first post,<br/>"; 
       } 
       else 
       { 
        // Code for second style 
        echo "HTML for the rest!"; 
       } 

       $i++; 
     } 
} else { 
     // no posts found 
} 

편집이다 : 죄송합니다, mismisread? 롤. 여기 있군요

+0

완벽, 정확히 내가 찾고 있던 것. –

관련 문제