Featured Image VS Post_thumbnail — has_post_thumbnail lies?

OK, I got a custom post type with thumbnail enabled which adds the “featured images” panel to that post-type just fine, but in my template when I do

if ( has_post_thumbnail() ) {
    the_post_thumbnail();
} else {
    echo 'none';
}

it just shows ‘none’ on each one even though I have a featured image set… I have add_theme_support('post-thumbnails',array('post','custom_post_type')); so it’s supported by the theme but has_post_thumbnail always returns false what’s going on here???

My template is :
archive-custom_post_type.php :

<?php
$loop = new WP_Query(array( 'post_type' => 'clients', 'posts_per_page' => -1 ));
if($loop){
?>
<ul>
<?php
while ( $loop->have_posts() ) : $loop->the_post();
?>
        <li>
            <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
            <?php 
                if ( has_post_thumbnail($post->ID) ) {
                    the_post_thumbnail('thumbnail');
                    echo get_post($post->ID)->post_excerpt;
                } else {
                    echo 'broken ::' . $post->ID;
                    echo get_post($post->ID)->post_excerpt;
                }

            ?>
            </a>
        </li>
<?php 
endwhile;
//wp_reset_postdata();
?>
</ul>
<?php
}
?>

Solutions Collecting From Web of "Featured Image VS Post_thumbnail — has_post_thumbnail lies?"

In your Custom Post Type, do you setup_postdata( $post ) in your custom Loop? If not, has_post_thumbnail() might not be defined/available?

EDIT:

Try adding:

setup_postdata( $post );

Right before:

$loop->the_post();

And then see if has_post_thumbnail() returns true?

Or, try passing the $post->ID to your call to has_post_thumbnail()?

has_post_thumbnail( $post->ID );

Try removing $post->ID from the has_post_thumbnail(). Perhaps the $post object isn’t referencing your current post.

Add this at the top of your functions.php

if( ! function_exists( 'has_post_thumbnail' ) )
{
    function has_post_thumbnail( $pid )
    {       
        return get_post_meta( $pid, '_thumbnail_id', true );
    }
}