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 Single Page

Debby Beachy
PLUS
Debby Beachy
Courses Plus Student 2,096 Points

Help please! My single-portfolio.php file is not show the images.

I looked at all of the threads and couldn't find my answer. I can see my text and my heading, but I can't see my image. Why? Imgur

If it's not the code...do I need to do something inside my ad-min?

Debby Beachy
Debby Beachy
Courses Plus Student 2,096 Points

[I found my answer!]

Just in case anyone else has this problem. My code is fine! However in my admin > custom fields > portfolio under field name I have a underscore after images.

Imgur

single-portfolio.php <?php the_field('images_'); ?>

At first I didn't put the underscore after images. What is weird I didn't see this in Zac's video so I didn't catch it. After going over the video twice I figured it out made the change and all is working great!

Kate Moore
Kate Moore
22,916 Points

thank you! turns out I just made the same mistake :)

1 Answer

caroline
caroline
6,974 Points

I had the same problem! For some reason I had originally left the 'field name' area blank when setting up the custom fields. Then, when I realised this, it still didn't work because I'd used a capital 'I' for 'Images' in the field name, but here in <?php the_field('images'); ?> I'd used a lower case 'i'. It didn't work until I used a capital 'I' in the php like this: <?php the_field('Images'); ?> to match what was in the custom field. I guess php isn't very forgiving!

caroline
caroline
6,974 Points

Oh, and just to add, I then had to go back to each portfolio piece and re-add the images into the WYSIWYG box as they hadn't previously saved (due to there being no 'field name' in the custom field). Only then did they show up on the page.