Get Featured Image

Display the featured image of a post in a tag.

echo get_the_post_thumbnail();

Additionally if you want to grab a specific size for the featured image you can fill out the second argument with an image size. Also can add class onto image.

echo get_the_post_thumbnail( get_the_ID(), 'medium', array('class' => 'img-fluid') );

Return the URL of the featured post image.

echo get_the_post_thumbnail_url( get_the_ID(), 'medium' );

Leave a Reply

Your email address will not be published.