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 trialPeter Reville
1,645 PointsWordpress Custom Post Type - missing images
I'm working through the custom post type UI video, and have added a page where art images are supposed to be displayed, but I get no image, just alternate text.
http://www.cpdrobot.com.gridhosted.co.uk/?page_id=24
I see from the forum that this happening to a lot of people, but nobody seems to have a straightforward answer. Can anyone help ? I've emailed Treehouse for help but the've told me to post - I'm new to this so go easy...
2 Answers
Saskia Lund
5,673 PointsCould you pls post your page template code? This seems to be a page, correct me if I'm wrong. If it's an archive, pls post your custom-post-type-archive.php content.
Peter Reville
1,645 Points<?php
/**
* Template for displaying art custom post type entries
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<h1 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<div class="entry-meta">
<p>Price: $<?php the_field('price'); ?></p>
</div><!-- .entry-meta -->
</header><!-- .entry-header -->
<div class="entry-content">
<p><img src="<?php the_field('image'); ?>" alt="Example image of <?php the_title(); ?>"></p>
<p><?php the_field('description'); ?></p>
</div><!-- .entry-content -->
</article><!-- #post -->
Rich Bagley
25,869 PointsHi Peter,
Are you using the Image field type to display the following?
<p><img src="<?php the_field('image'); ?>" alt="Example image of <?php the_title(); ?>"></p>
If so, I'd recommend selecting the Image Object Return Value. You can then use the examples here to display the images. An alternative would be to use the Wysiwyg Editor field type where you could upload the images as you would on a normal page.
Hope that helps :)
-Rich
Rich Bagley
25,869 PointsRich Bagley
25,869 PointsHi Peter,
Welcome to Treehouse! Can you post your code please and we'll take a look? :)
Thanks
-Rich