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

Solution for Portfolio Page not displaying "portfolio" type posts and featured images

Here is how I fixed it (not that I understand the replaced code):

  1. Opened page-portfolio.php from downloaded project files under this video.

  2. Compared it to my own page-portfolio.php (identical to the tutorial video).

  3. Noticed Line 24 of downloaded project file: <?php get_template_part('content', 'portfolio'); ?>

  4. Opened project file "content-portfolio.php". Here the php block with WP_Query (line 1-11) has extra code:

<?php 

  $num_posts = ( is_front_page() ) ? 4 : -1;

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

?>

my php block with WP_Query from following the tutorial had only

<?php

  $args = array(
    'post-type' => 'portfolio'
  );
  $query = new WP_Query( $args );

?>

I replaced my original WP_Query block with the one from "content-portfolio.php".

Now it works - the portfolio page is displaying "portfolio" posts and featured images.

1 Answer