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

Portfolio isn't showing images or Description

I've looked over my code a ton of times and just can't figure out why they aren't displaying

'''<?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>
  </div>
</section>

<?php

$args = array( 'post_type' => 'portfolio' );
$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(); ?>

    </section>

<?php get_footer(); ?>'''

this is my current code

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

You probably need to add support for your fields in custom post types.

In the admin area, go to your CPTUI plugin, edit the "portfolio" custom post type and scroll down to the "supports" settings. Make sure that images and supports are checked and then th fields should show up when you add a new portfolio post.

Elena Paraschiv
Elena Paraschiv
9,938 Points

Imgur

It still does not display the image or the description in the custom post types

/==================================/

i fixed it. I forgot to add feature image. After I did that, the image displayed

I'm doing the same as in videos and all is going good, but In edit page, there is no Portfolio Page template available to select from drop down list, as Zac did in video at time 1:25. The options available there are only "Default Template" and "Left Sidebar". Plzzz Help meeee!!!!