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 trialStephanie Roberts
16,757 PointsImage is not showing up on portfolio page
I have re-checked my code a dozen times and made sure everything on the backend is correct and I still cannot see my image display on the portfolio page. Could someone please help? I have been stuck on this for a while now and want to continue with the course.
4 Answers
Stephanie Roberts
16,757 Points /* 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(); ?>
Mohsen Qaddoura
22,237 PointsStephanie Roberts, you missed : the php tag at the very beginning of your file. Every PHP file must start with it. So at the top of your code, up to your comment should be :
<?php
/*
Template name: Portfolio Page
*/
?>
Mentor Kadriu
2,409 PointsIn the admin area, go to CPT UI plugin -> Add/Edit Post types -> Edit Post Types. Scroll down till end, you will see a section called Supports and check Featured Image .
Caden Adam
16,257 PointsI had the same issue, what you have to do is add an <img /> tag before the_post_thumbnail code:
<a href="<?php the_permalink(); ?>"><img /><?php the_post_thumbnail( 'large' ); ?></a>
Thomas van der Zel
16,796 PointsThomas van der Zel
16,796 PointsCan you provide us the code you wrote?