Skip to content
WJunction - Webmaster Forum

How to show featured image custom post type?

Status
Not open for further replies.
Hello guys,

Can someone please give me a little help here?

I need to show a custom post type feature image in my single.php.

I am trying this code:
PHP:
<?php the_post_thumbnail('freeGallery', array('class' => 'imgthumb')); ?>

But without success...
It shows the post (single.php) featured image and not the custom post (freeGallery) featured image.

What Im doing wrong? :P

Thanks!!

__________________
Added after 19 Hours 16 minutes:

This is my code, but isn't working... Is only showing the post featured image and not the custom post type featured image.
Can someone tell me what I'm doing wrong?

PHP:
<?php
$loop = new WP_Query(array('post_type' => 'freeGallery', 'post_status' => 'publish'));
?>
<td><div class="gallerycontainer">
<a class="bestthumbnail" target="_blank" title="<?php echo $post_title; ?>" href="<?php echo get_post_meta($ID,'mr_freeGalleryUrl',true); ?>" rel="nofollow"><?php $title = $post_title; if (strlen($title) > 85){ echo substr($title,0,85).'...';}else { echo $title;}?><span><?php the_post_thumbnail('freeGallery', array('class' => 'imgthumb')); ?></span></a></div></td>

Thanks :)
 
Last edited:

1 comment

<?php
$loop = new WP_Query( array( 'post_type' => array('freeGallery')&'post_status=publish'));
if ( $loop->have_posts() ) : $loop->the_post(); ?>
<div><?php echo the_post_thumbnail(); ?></div>
<?php endif; ?>

Try this
 
Status
Not open for further replies.

About the author

D
Active Member · Joined
806
Messages
18
Reactions
18
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom