将帖子限制在特定的类别和子类别
问题描述:
本网站: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/但由于我没有写这段代码,我不知道如何修改它。
答
您可以在阵列过去的类别get_posts
$args = array('numberposts' => 18, 'post_status'=>"publish",'post_type'=>"post",
'orderby'=>"post_date", category=>82);