开发者

How to get the total number of Wordpress Posts from an Author ID?

开发者 https://www.devze.com 2023-04-06 05:12 出处:网络
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

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().

0

精彩评论

暂无评论...
验证码 换一张
取 消