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

Diane Frierson
2,311 PointsDisplaying Custom Posts and Fields in a Template
Hi everybody, I have watch the video several times and i still cant seem to pull the work post to the work page? I dont know what I am doing wrong:(<?php
/*
Template Name: Work Page
*/
get_header(); ?>
<p>This is the work.php Dee</p>
<?php
$args = array(
'post_type' => 'work'
);
$the_query = new WP_Query( $args );
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h3><?php the_title() ;?></h3>
<?php the_content(); ?>
<hr>
<?php endwhile; else: ?>
<p>There are no posts or pages here</p>
<?php endif; ?>
<?php get_footer(); ?>
12 Answers

Patricia Neale
9,256 PointsHi Diane,
I was having the same problem until I realised that I had not actually set up any work posts! The video shows 4 posts (Stop Visual Pollution, Dr Watz, Smells Like Bakin', Shirts 4 Mike) but, as far as I can see, at no point have we been asked to create them. This is what is causng the confusion. Anyway, I just set up a couple of test work projects from the admin menu. I will do the same for testimonials. Hope this helps.

Kevin Korte
28,148 PointsOn your work page in your admin, where you can set the page title and context, in a box on the right of the screen, there is a dropdown for selecting a page template. There should be an option of Work Page now available. Select that, and than click the button to update the page.

Diane Frierson
2,311 PointsHi Kevin, yes I do have that selected.

Kevin Korte
28,148 PointsOkay, and do you have a custom post type set up called 'Work'? Are you using the Custom Post Type UI plugin?

Diane Frierson
2,311 PointsYes, I installed both plugins and I have a custom post type titled 'Work'

Matt Campbell
9,767 PointsI'm guessing nothing is coming up on the page at all or just one post? I'm not seeing any curly braces around your loop.

Diane Frierson
2,311 PointsActually the the content that I pasted on the page is showing along with the title, but no post. And curly braces are not included because the video did not instruct it.

Diane Frierson
2,311 PointsDose anyone know if there is compress folder that I can download to compare my code with?

Kevin Korte
28,148 PointsYour title says custom fields, but I do not see any custom fields in your code. What custom fields are you trying to show?

Diane Frierson
2,311 PointsDisplaying Custom Posts and Fields in a Template 7:08 is the title of the course that I am taking and having trouble with.

Diane Frierson
2,311 PointsThanks Patricia, I did try creating a work category but that still did nt work for me. I'll keep trying. Do you know if there's a completed project file we could download to compare our work to. That would save time:)

Diane Frierson
2,311 PointsI found the completed project files they are in the Converting Static HTML into WordPress Templates course. Thanks Tree House your the Best:)
Winnie E Tibingana
21,066 PointsWinnie E Tibingana
21,066 PointsYes, adding test work projects works. Thanks Patricia.