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 trialNikolaj Dinesen
6,903 PointsCustom post type - show single post - problem!?
Hi there
I have tried almost everything now, and still don't get why it's not working. I have on my testsite-environment created 2 custom post types. 1) The example in the lessons with artworks. - It works fine! 2) One called argentinarejser (danish word (rejser = travel)) and it doesn't work.
What is not working is, that i cannot show a single post. If i make a page and choose the template to show every posts it works fine But to show a single page with post type 'argentinarejse' does not work.
Anyone know what could be wrong?
Thank you in advance!
2 Answers
Jeffrey Smith
Courses Plus Student 15,508 PointsI had a similar thing happen on with the custom post types on a site I was working on. I finally got the single posts to display by adding the following function at the end of my Register Custom Post Type function:
flush_rewrite_rules( false );
James Pask
13,600 PointsI had the same issue and thought I was going crazy. I was following the portfolio example but with drinks. I'd created a template file called single-drink.php and I just kept getting a 404 page. In my situation I [appear to have] fixed it by going back into the 'Add/Edit Post Types' screen in the admin area and putting a check in the 'Migrate posts to newly renamed post type?' box (after going in to the 'Drinks' post type. I didn't edit anything else but that appears to have sorted it.
Nikolaj Dinesen
6,903 PointsNikolaj Dinesen
6,903 PointsHi, and thank you.
It didn't work for me, so i started over with new post type, for some strange reason it works now. Its the exactly same php files i used for the other one. I only changed the slug all the way through. Strange..
Good day to you!