主题开发过程中如果需要在文章页显示当前文章分类的置顶文章可参考如下代码:
<dl>
<dt><span>置顶</span>推荐</dt>
<?php
wp_reset_query(); //重置搜索
$category = get_the_category(); //读取当前页面分类信息
query_posts('cat=' . $category[0]->cat_ID); //查询指定分类文章
if (have_posts()) : ?>
<?php while (have_posts()) : the_post();
if (is_sticky()):
//输出置顶文章
?>
<dd>
<p class="rList_title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></p>
<p class="rList_img"><?php the_post_thumbnail(); ?></p>
<span class="rList_tag"></span></dd>
<?php else:
//非置顶文章
?>
<?php endif; ?>
<?php endwhile; ?>
<?php else: ?>
<dd class="nothing">暂无文章...</dd>
<?php endif; ?>
</dl>
将以上代码放置于你的页面模板single.php即可。