2013-10-17 164 views
0

我有以下代碼,顯示在家庭的最新帖子。如何編輯此代碼以顯示來自特定類別的最新帖子?因爲我需要顯示來自3個類別(酒店,路徑和博客)的帖子。WordPress的 - 顯示從特定類別3最近的帖子

<!-- LOOP START --> 
<?php $the_query = new WP_Query('showposts=3'); ?> 
    <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> 
    <!-- THIS DISPLAYS THE POST THUMBNAIL, The array allows the image to has a custom size but is always kept proportional --> 
     <div id="hotele"><a href="<?php the_permalink() ?>"> <?php the_post_thumbnail(array(349,349));?></a> 
     <!-- THIS DISPLAYS THE POST TITLE AS A LINK TO THE MAIN POST --> 
     <div><h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2></div> 
     <!-- THIS DISPLAYS THE EXCERPT OF THE POST --> 
     <li><?php the_excerpt(); ?></li> 
     </div> 
    <?php endwhile;?> 
<!-- LOOP FINNISH --> 
+0

谷歌'wp_query' – codepixlabs

回答

0
$args = 'showposts=3&cat=1,2..'; 

or 

$args = 'showposts=3&category_name=category_slug_1,category_slug_2...'; 

<?php $the_query = new WP_Query($args); ?> 

採取看看WP_Query手冊。

0

您可以使用

wp_get_recent_posts('numberposts=5&category=8')  
+3

你能也許擴展更多的對你的解答或描述如何解決這個問題? – Illidanek

相關問題