Wordpress - 显示侧栏"特定帖子"中特定类别的帖子

pix*_*ode 5 wordpress

如何让WP边栏中的"最近帖子"显示来自特定类别的帖子?

mar*_*dge 5

可能最简单的方法是使用Otto的PHP代码小部件http://wordpress.org/extend/plugins/php-code-widget/创建一个自己最近的帖子小部件 和一个新的查询:

<?php $my_query = new WP_Query('category_name=mycategory&showposts=1'); ?>

<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

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

<?php the_title(); ?></a>

<?php endwhile; ?>
Run Code Online (Sandbox Code Playgroud)

以任何你想要的方式设计它.新的查询循环不会与主WP循环冲突,可以使用任意数量的时间.