Display 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 the_author_posts() to display the posts count.

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() {
    ob_start();
    the_author_posts();
    return ob_get_clean();
});

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