Multiple post_types with the function count_user_posts
-
Hi,
I see since 4.1 that this function allows you to see how many posts a user has published within custom post types.
For example, I can find out how many posts user 9 has published under the post type ‘film’ by using
count_user_posts( 9 , "film" )
However, is there a way that I can get the count for all of his posts from all our post types combined rather than just the one?
Up until yesterday I had been using this…
$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); $args = array( 'author' => $curauth->ID, 'post_type' => 'any' ); $posts = new WP_Query($args); $post_count = $posts->found_posts;
That was until it stoped working for me in the application I need it to (page of authors).
Any help would be much appreciated,
Sam
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Multiple post_types with the function count_user_posts’ is closed to new replies.