当前观看作者的贴子?

时间:2015-04-19 作者:Advanced SEO

如何在作者上显示当前浏览作者的贴子。php模板?

$sticky = get_option( \'sticky_posts\' ); 
rsort( $sticky ); 
$sticky = array_slice( $sticky, 0, 5000 );
query_posts( array(
\'post__in\' => $sticky,
\'author\' => $current_user->ID,
\'orderby\' => \'rand\',
\'post_type\' => \'post\',
\'post_status\' => \'publish\', 
\'posts_per_page\' => 5,
\'caller_get_posts\'=> 5 
) );
这很好,但它显示了所有作者的贴子,而不仅仅是当前查看作者的贴子。

1 个回复
SO网友:Advanced SEO

我找到丢失的内容($wp\\u query->queryed\\u object\\u id;),答案如下:

$current_browsing_author = $wp_query->queried_object_id; // Get current browsing author
$sticky = get_option( \'sticky_posts\' ); 
rsort( $sticky ); 
$sticky = array_slice( $sticky, 0, 5000 );
query_posts( array(
\'post__in\' => $sticky,
\'author\' => $author,
\'orderby\' => \'rand\',
\'post_type\' => \'post\',
\'post_status\' => \'publish\', 
\'posts_per_page\' => 5,
\'caller_get_posts\'=> 5
) );

结束

相关推荐

Get x recent posts by author?

因此,我的网站上有十位作者,我想指定一个部分,以帖子标题链接的形式显示这十位作者及其5篇最新帖子。我尝试使用以下<?php get_most_recent_post_of_user( $user_id ); ?> 但它不起作用,所以我觉得有点失落。有什么建议/建议吗?