Displaying the authors list of current category’s posts

Displaying the authors list of current category’s posts on category archive page. It is listing below the entry content. Here is the snippet:

This content is only available to members. You must subscribe the monthly membership plan ($.9.99 USD).

Explaining the above code:

18-19: Return early if user is not visiting the category archive page. Checking this using is_category() conditional tag.
22: Saving the queried object in a variable $term_obj. Using this variable I am fetching the current category ID.
24-29: Generating the query args for get_posts() function. See the codex
32-37: Making the array of unique authors from posts.
40-54: Showing all the authors’ nickname with author’s profile link. For author details I used the get_userdata() function. It is returning the object with some parameters. See the codex for better knowledge. For front end output I used PHP’s printf() function.

Let me know if you have any queries. I shall feel free help you.

Share This Article

Subscribe Membership Plan ($9.99/mo)

  • Get full access to all premium tutorials
  • Get Support for the posted content
  • Request for specific how-to tutorials
  • Cancel the subscription at anytime

Reader Interactions

Leave A Reply

Your email address will not be published. Required fields are marked *