2013-08-16 75 views
0

如何在Wordpress中的循環外部顯示並創建具有最新帖子的框?我在這個鏈接http://i.imgur.com/UbBvlnE.png的圖片上展示了這一點。我在紅框中談論這個;) 對不起,我的英語。如何在Wordpress中的循環外顯示最新的帖子?

我用我的所有職位的砌體CSS在網頁http://sickdesigner.com/masonry-css-getting-awesome-with-css3/

這是循環代碼:

<div class="all_center"> 
<?php query_posts($query_string."&orderby=post_date"); ?> 
     <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
       <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> 

         <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> 


<?php the_post_thumbnail('mediumImageCropped'); ?> 
         <div class="entry"> 
         <?php the_excerpt(); ?> 
<div class="postmetadata"> 


         </div> 
</div> 
</div> 


     <?php endwhile; ?> 



     <?php else : ?> 

       <h2>Not Found</h2> 

     <?php endif; ?> 

</div> 
+0

很難幫助不知道到目前爲止你做了什麼 – vroomfondel

回答

0
$recent_posts = wp_get_recent_posts(array('numberposts' => '1')); 

echo get_the_post_thumbnail($recent_posts[0]['ID'], 'thumbnail'); 

echo $recent_posts[0]['post_content']; 
+0

謝謝,但現在我的帖子是重複的。它位於最新框和循環中的循環外部。看起來像這樣http://i.imgur.com/8NyFqLt.png – Krystian

+0

是的,你可以在循環之外使用此代碼,並且可以跳過循環中的第一篇文章 –

+0

如何跳過循環中的第一篇文章? – Krystian

相關問題