我有一个多作者的wordpress网站,每个作者都可以发布两种不同帖子类型的帖子。我想在author中按帖子类型显示作者帖子数量。php。根据法典。wordpress我使用了这段代码:但它显示的是总帖子数,而不是作者帖子数。
<?php echo \'Number of posts published by user: \' . count_user_posts( $userid , "book" ); ?>
最合适的回答,由SO网友:Gidromasservis QSC 整理而成
This solved
$author_id = get_queried_object_id(); //get author id
echo \'Number of posts published by user: \' . count_user_posts( $author_id , "custom-post-type" ); ?>