How to get the total number of Wordpress Posts from an Author ID?
I've been scouring everywhere and can't seem to find this. I k开发者_如何学运维now the WP variable within the loop can use $post_count
but I'm writing from an external function. I've set global wp_query
so I should be able to pull out the number, and I have the user IDs as well.
Any help would be more than appreciated :D
Take a look at wp-includes/author-template.php. It includes various functions for pulling author data for display in a theme.
In this case, I think you are looking for count_user_posts($userid). If you are retrieving more than just post counts, you may want to create another instance of WP_Query().
精彩评论