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 From Bootstrap to WordPress Create Bootstrap Styled Theme Templates Creating a Portfolio Landing Page

CERRA CERRA
CERRA CERRA
2,903 Points

For some reason my query is echoing out my regular posts instead of the ones set in the array as post-type-> 'portfolio'

Is this broken ? I have everything set up exactly as show in the video <div class="row"> <?php

      $args = array(
        'post-type' => 'portfolio2');
      $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>

This is only displaying my REGULAR posts (Hello World! etc.) instead of the ones created with the new post type portfolio with CPT UI,.... Am I missing here?

2 Answers

David Richied
David Richied
18,057 Points

Just change post-type in your array to post_type with an underscore instead of a hyphen, and it should work. :)

Jill Ferron
Jill Ferron
5,023 Points

Thanks I had the same issue, the underscore fixed it

Jill Ferron
Jill Ferron
5,023 Points

Thanks I had the same issue, the underscore fixed it

CERRA CERRA
CERRA CERRA
2,903 Points

My post type slug is actually portfolio2, sorry for the confusion