Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


[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!


2 Answers

Kevin Korte
Kevin Korte
28,109 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".


Thank you very much Kevin! Problem solved :)