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 WordPress Theme Development Custom Post Type Templates in WordPress The Portfolio Homepage

Sandra Murphy
Sandra Murphy
Courses Plus Student 101 Points

My images won't appear on portfolio page?

Here is my page-portfolio.php code

<?php /* Template Name: Portfolio Page */ ?> <?php get_header(); ?>

<section class="row"> <div class="small-12 columns text-center"> <div class="leader">

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

  <h1><?php the_title(); ?></h1>            
  <?php the_content(); ?>

<?php endwhile; endif; ?>


</div> </section>

<section> $args = array( 'post_type' => 'portfolio', 'posts_per_page' => $num_posts ); $query = new WP_Query( $args );


<section class="row no-max pad">

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

<div class="small-6 medium-4 large-3 columns grid-item"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('large'); ?></a> </div>

<?php endwhile; endif; wp_reset_postdata(); ?>


<?php get_footer(); ?>

4 Answers

My images are not showing up either.

  • No broken image, images just not showing at all
  • Yes the post has a feature image assigned. If I enter text inside a <p> it shows up, but an <img src> shows nothing.

Please help.

so i figured it out! The new verions of Custom Post Types will not let you name the post type "Portfolio" because there is already a page with that name. I named mine "portfolio_piece" Therefore the 'post_type' => 'portfolio_piece' instead of 'Portfolio'


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

Flor Antara
Flor Antara
12,372 Points

Hello Sandra,

A couple of questions to help you debug this piece of code:

  • Are the images not showing up at all or they are showing a broken image resource (404)?
  • Are you sure that the posts have Featured Images assigned?
  • I see that you want to use the "large" size. It is possible, that the image you uploaded as the Featured Image is smaller than what the "large" size specifies. If that's the case, WordPress won't find the "large" size for your image, thus not showing anything. You might want to go with just "full" or upload larger images.

you're very welcome!

Of course!

Great Job David! Thanks! Helped me as well...

You are welcome. Glad to help.