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 How to Make a Website with WordPress Custom Post Types and Fields in WordPress Setting Up Custom Post Types and Fields

Martin Švec
Martin Švec
8,208 Points

Content of custom post type is not showing

I followed all the steps in the video to make a custom post type, but discovered that the content of my posts made this way are not showing up when viewing my page.

I found on the forum for this video that in order to make this work I have to set up the template files for your archive-{post type}.php and single-{post type}.php files in your theme.

Even after I did that, I am still not getting any results. I was then looking for an answer elsewhere on google and found out that I might need to put some query into to the code as well. I don't have any knowledge of query yet so I don't know what need to be done. Could someone please tell me what to do to make it work.

Thank you all for your answers

Hi Martin,

Can you post your code please?

Thanks

-Rich

Martin Švec
Martin Švec
8,208 Points

Hi Rich,

I added this code I found on the internet to my child theme.

<?php

$args = array( 'post_type' => "art"); $query = new WP_Query( $args );

?>

2 Answers

Hi Martin,

It sounds as though you need to create the custom post type template. That should be the next video in the course and can be found here. This goes through the process step-by-step.

That should hopefully help you to choose what is shown on the page.

-Rich

Martin Švec
Martin Švec
8,208 Points

Thank you Rich,

I completed this course, but somehow managed to skip this video. Thank you for answering my silly question.

No problem. Don't forget to mark it as Best Answer if that sorted your problem :)

-Rich