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 user220637user220637
Add a comment  | 

1 Answer 1

Reset to default 0

The 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