[resolved] Display featured image from a custom post type (2 posts)

  1. rikardo85
    Posted 3 years ago #


    I have created a custom post type called main image.

    Once the custom post type is selected, I have just the featured image box on the right hand side.

    I enter an image and it saves with no problems.
    I am having trouble displaying the featured image on the front end of the site.

    I know that a query is used to achieve this but I haven't got a clue on how to do this.

    Has anyone got any ideas on how I do this?


  2. rikardo85
    Posted 3 years ago #

    No worries, I found a solution:

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

Topic Closed

This topic has been closed to new replies.

About this Topic