Displaying the authors list of current category’s posts on category archive page. It is listing below the entry content. Here is the snippet:
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.
Leave A Reply