admin管理员组文章数量:1203823
I'm trying to set up users archive pages;
I notice that, if a user exists and is the owner of a custom post, it doesn't have an archive page;
so I looked inside user.php in order to include custom posts in the function count_user_posts
,
the original function was
function count_user_posts( $userid, $post_type = 'post', $public_only = false ) {}
and I changed it to
function count_user_posts( $userid, $post_type = array('post','blog','lettura','intervista'), $public_only = false )
this didn't work, so I'm wondering where is the function that assigns archive pages to users
thanks in advance
I'm trying to set up users archive pages;
I notice that, if a user exists and is the owner of a custom post, it doesn't have an archive page;
so I looked inside user.php in order to include custom posts in the function count_user_posts
,
the original function was
function count_user_posts( $userid, $post_type = 'post', $public_only = false ) {}
and I changed it to
function count_user_posts( $userid, $post_type = array('post','blog','lettura','intervista'), $public_only = false )
this didn't work, so I'm wondering where is the function that assigns archive pages to users
thanks in advance
Share Improve this question edited Mar 29, 2022 at 10:02 Tom J Nowell♦ 60.8k7 gold badges77 silver badges147 bronze badges asked Mar 29, 2022 at 9:30 user220637user2206371 Answer
Reset to default 0The count_user_posts
accepts array as the $post_type
arguments. You don't need to include the $post_type =
part.
$user_posts = count_user_posts( $userid, array('post','blog','lettura','intervista') );
The $user_posts
variable will hold the number of posts for the $userid
.
本文标签: users post count
版权声明:本文标题:users post count 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738656100a2105150.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论