Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress WordPress Theme Development Custom Post Type Templates in WordPress The Portfolio Homepage

image not showing for custom 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>

</div> </section>

<section class="row no-max pad">
  <div class="small-6 medium-4 large-3 columns grid-item">
    <a href="item.html">
    <img src="assets/img/temp/item-01.png" alt=""></a>
  </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(); ?>

1 Answer

Are you sure that your image file is located in that folder?

I think you should include the entire url

<img src="/wp-content/themes/your-theme/assets/images/example.jpg" />

I hope this fix your problem!

Kyle Shamblin
Kyle Shamblin
9,945 Points

You don't need the second block of code you posted, I would erase it. The PHP functions you added below are supposed to replace it. Now, about the featured image, I had to go into the Pink Triangle post and choose a featured image manually. I'm not sure if this is what we're supposed to do but I added a question to the forum asking this.

Good luck! :)