Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Displaying related posts on single.php page

Hello,

I am wanted to display a list of posts in a table format that are in the same category as the single post being currently view. How could I accomplish this?

Jacobus Hindson
Jacobus Hindson
14,429 Points

Hey Joel,

What you can do is set a variable for the 'catergory__in' parameter in your WP_Query that was dynamically set when loading the single.php then add a code block that called that same variable and add a list of items that calls "the_permalink()" and "the_title()".

Look at more information at the Codex.

I have an example on another machine when I get to that office I will post a code block for you