1. Code
  2. WordPress

Quick Tip: After the Content - More From This Category

This post is part of a series called After the Content.
Quick Tip: After the Content - Disclaimer
Quick Tip: After the Content - Share This

Do you have a solid construction of categories on your blog? If so, you might not need a "Related Posts" section at all - you can just display latest posts from the same category.

In this post, we're going to go through the "More From This Category" section, an alternative to "Related Posts" (which we covered earlier).

Show You Have More to Say

If you keep your posts organized well with categories, you might find it useful to have a list of posts from the post's category.

"Related Posts" is not always the answer: If you have a website where the posts are separated with categories, a "Related Posts" section might "break" this separation.

For example, if you have a blog about different occupational groups, you can't show news about the textile sector as "Related News" under a post about informatics. A number of latest posts from the same category would be more relevant, right?

Creating a "More From This Category" List

As you may have guessed, listing latest posts from a post's category will be much easier than displaying related posts based on a post's tags. We just need to get the category of the post and list a number of posts from that category, excluding the post that the visitors have just read. The arguments that we can pass in the get_posts() function has everything we need.

Done! You can include this function inside your functions.php file (or save it as a separate plugin) and echo it (as <?php echo wptuts_more_from_cat( 'More From This Category:' ); ?>) anywhere you want inside your single.php file.


Yes, content may be "king" but a lonely king is a weak king, and people might not respect that "king".

Do you think there are more page elements that can help "the king"? Post your comments below - it's always important for you to share your thoughts with us!

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.