Get posts count of current author

Advertisement

Most of the times we need to display the number of posts written by current post author.

In WordPress, We can use the function get_the_author_posts() to display the posts count.

get_the_author_posts();

You can use it in the single post, page, or custom post type template.

Or

You can also use display the post count with custom shortcode like below:

E.g.

add_shortcode( 'author_post_count', function() {
    return get_the_author_posts();
});

Here, We have created a shortcode [author_post_count] which display the current post author posts count.

Leave a Reply