worspress获取作者其他文章的办法

在WordPress中的文章页我们可能需要获取到作者的相关文章,推荐给作者更多阅读的内容,我们可以使用query_posts()自定义Loop循环,在文章页有一个全局的$post变量,通过$post->post_author获取作者的ID,所以获取相关作者的文章,功能代码如下:

$args = array(

‘post__not_in’ => array($post->ID),

‘showposts’ => 6, // 显示相关文章数量

‘orderby’ => date, // 按时间排序

‘post_author’ => $post->post_author

);

query_posts($args);

if (have_posts()):

while (have_posts()):the_post(); update_post_caches($posts); ?>

相关推荐

发表回复

房先生
我们将24小时内回复。
2024-05-11 06:08:06
您好,有任何疑问请与我们联系!
您的工单我们已经收到,我们将会尽快跟您联系!
[QQ客服]
2781198
加我微信
[电话联系]
13585372227
[电子邮件]
chaoneo@163.com
取消

选择聊天工具: