How to Display Featured Image from Custom Post Type

You can get and display the custom post type featured image by using the_post_thumbnail() function inside the your custom post type loop or templates file.

<?php the_post_thumbnail(); ?>

However, If you want to show featured image outside the loop or any other location instead of custom post template file, then you can use get_the_post_thumbnail($post_ID) function. With this function, you have to pass the custom post ID.

<?php echo get_the_post_thumbnail($post_ID); ?>

You can also get custom post type featured image URL by using get_the_post_thumbnail_url($post_ID) function and use it with the image tag to display the featured image (as shown below).

<img src="<?php echo get_the_post_thumbnail_url($post_ID);?>" />
Owner of, solely responsible for creating helpful, informative content about WordPress, a fulltime WordPress developer with 8+ years of hands-on experience in WordPress design and development.