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

Custom post type 'portfolio' is not returning on the WP_Query.

I can't seem to get the query to return the list of porfolio items. I've reviewed the code from the project downloads and can't find any discrepancies. This leads me to believe it could be an issue with the plugin or a new update. Does anyone have any suggestions on how to fix this?

Here is my code so far:

<!-- Template name: Porfolio Grid --> <?php get_header(); ?>

<div class="container"> <div class="row">

    <div class="col-md-12">
        <?php if (have_posts()) : while(have_posts()) : the_post(); ?>

            <div class="page-header">
                <h1><?php the_title(); ?></h1>
            </div>

            <?php the_content(); ?>

        <?php endwhile; else: ?>

            <div class="page-header">
                <h1>Sorry!</h1>
            </div>
            <p>There is no content for this page!</p>



        <?php endif; ?>
    </div>
</div>

<div class="row">

    <?php 

        $args = array(
            'post_type' => 'portfolio'
        );
        $the_query = new WP_Query($args);

    ?>

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

    <div class="col-sm-3 portfolio-piece">

        <h3><?php the_title(); ?></h3>

    </div>

    <?php endwhile; endif; ?>

</div>


<?php get_footer(); ?>

</div>