将帖子限制在特定类别和子类别
Restricting posts to a specifc category and subcategory
在这个网站上: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; ?>
post 应该限制在特定类别 (#82) 及其中的任何子类别。我知道如何使用传统的 post 显示来做到这一点: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);
在这个网站上: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; ?>
post 应该限制在特定类别 (#82) 及其中的任何子类别。我知道如何使用传统的 post 显示来做到这一点: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);