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


Shawn Mathew
Shawn Mathew
6,574 Points

How To Build a Wordpress Theme Project

Hello All,

I'm going thru the "How to Build A Wordpress Theme" project and am getting stuck at the displaying custom post types portion. Here is the code for my work.php file:


Template Name: Work Page

get_header(); ?>

<p>This is the work.php file.</p>


    $args = array(
        'post-type' => 'work'

    $the_query = new WP_Query( $args );


<?php if( $the_query->have_posts() ): while( $the_query->have_posts() ): $the_query->the_post(); ?>

    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    <?php the_field( 'description' ); ?>

<?php endwhile; else: ?>

    <p>There are no posts or pages.</p>

<?php endif; ?>

<?php get_footer(); ?>

This does not return the posts from the custom post type 'Work' but instead displays the regular posts from the blog page. Any ideas what I'm doing wrong? Thanks for any help!

1 Answer

Shawn Mathew
Shawn Mathew
6,574 Points

Sorry All,

This was a simple syntax error, I was using "post-type" instead of "post_type".