Display number of posts by user, only if they have any.
-
I am using a plugin shortcode to display a list of blog posts by users on their own custom post type (sort of a user profile page).
I am using this code to display the number of posts
<h3><?php the_author(); ?> has contributed <?php the_author_posts(); ?> articles to the blog</h3>
and below that goes the shortcode.
How do I display this only if the user has made contributions to the blog. At the moment it says “(User) has contributed 0 articles to the blog” or “(User) has contributed 1 articles to the blog”
I would also like it to use the singular “article” if the number is 1.
Samples: https://www.teachmemusic.com.au/listings/more-test/
https://www.teachmemusic.com.au/listings/test-required-fields/about half way down the page.
Thanks.
- The topic ‘Display number of posts by user, only if they have any.’ is closed to new replies.