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

[RESOLVED] Custom portfolio detail page unable to load single-work.php page content

Hi everyone,

I've watched all of the 'How to Build a Wordpress Theme' videos, taken the quizzes and now I've started to build my own custom Wordpress site. I found the tutorials very helpful but am totally stumped on one thing - how do I link the single-work.php file to the work detail pages? Right now I've created each of the work pages (filled with content) but when I click on the preview images on the work page I am brought to a page with no content on it. Anyone know the answer to this?

Thanks a lot!

Cassie

2 Answers

Kevin Korte
Kevin Korte
28,149 Points

Is your custom post type called "work"? Wordpress operates on a template hierarchy, so when you have a custom post type, and want to display the single post of that work type, it is going to look for a file called single-{post-type-name}.php. If it can't find that page, it will fall back to the single.php file.

Also make sure in your single-work.php file you are running a new WP_Query and are querying for the custom post type "work".

http://codex.wordpress.org/Template_Hierarchy

Thank you very much Kevin! Problem solved :)