我有一个包含模板No Sidebars
的页面我想在作者姓名=页面标题的作者页面上列出5个帖子的标题
任何想法如何在不使用任何插件的情况下这样做?
我认为query_posts函数可以解决这个问题但this important note告诉我我不能使用query_posts
答案 0 :(得分:1)
这里有一些代码可能会让你获得作者的帖子标题;为了让它自动输出页面标题,我会有你的标题生成代码...希望这可以帮助你至少获得部分方式...
<?php $my_query = new WP_Query('author_name=YourAuthor&showposts=5'); ?>
<?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; ?>
答案 1 :(得分:1)
在Function Reference/WP Query « WordPress Codex
查看Wordpress display featured posts outside of loop和更早的答案(使用相同代码:)作为poindexter's)