2017-06-05 112 views
1

本網站:http://www.palmbeachwoman.com/stories/我使用程序員來定製模板。他的代碼爲:將帖子限制在特定的類別和子類別

<?php 

$args = array('numberposts' => 18, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date"); 

$postslist = get_posts($args); 

echo '<ul id="latest_stories">'; 

foreach ($postslist as $post) : setup_postdata($post); ?> 

<li><a href="<?php the_permalink(); ?>" title="<?php the_title();?>"> 

<span class="s_thumb"> <?php the_post_thumbnail('full'); ?> </span> 

<span class="s_title"> <?php the_title(); ?> </span></a> 

<span class="s_cotegories">More Stories from <?php the_category(', '); ?></span></li> 

<?php endforeach; ?> 

帖子應該被限制在一個特定的類別(#82)和其中的任何子類別。我知道如何在傳統的後期展示中做到這一點:http://alijafarian.com/how-to-display-wordpress-posts-for-a-specific-category/但由於我沒有寫這段代碼,我不知道如何修改它。

回答

0

您可以在陣列過去的類別get_posts

$args = array('numberposts' => 18, 'post_status'=>"publish",'post_type'=>"post", 
'orderby'=>"post_date", category=>82);