how do I display a featured image in a post type?

I have a single-posttype.php and I’m trying to figure out how to display the image

Related posts

Leave a Reply

2 comments

  1. <?php 
         $loop = new WP_Query( array( 
            'post_type' => 'yourPostTypeName',   /* edit this line */
            'posts_per_page' => 15 ) );
    ?>
    
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>  
    
         <?php the_post_thumbnail(); ?>
    
    <?php endwhile; ?>   
    

    This code also doesn’t work? I believe you’re listing everything fine (titles, excerpts etc.) & thumbnails only doesn’t show? How do you add them? Do you see them in down right corner on edit pages?

    If not change the_post_thumbnail function to:

    <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?> 
    echo $url
    

    is it showing thumbnail’s address?

    There are two options:

    a) you’re NOT adding thumbnails (to do so, click “Set featured image”, select/upload an image and THEN click “Use as featured image”, the image should appear in the right down corner),

    b) you have no loop (use my first code on page-posttype.php to create one).

    Please click the icon under the arrows on the left side if somebody helps you, your accept rate is dramatically low and many people don’t care about you.