WordPress: Outputting the Featured Image


Web Development

Updated Apr 12th, 2021

Super simple! Just use the_post_thumbnail(‘medium’) inside php tags.

Output the featured-image as an inline style using background-image: url() does not work with the_post_thumbnail() since this outputs and image tag. I also tried echoing get_the_post_thumbnail and get_the_post_thumbnail_url to no avail so need to dig a little deeper on this.

In WP if there’s no featured image uploaded can you set a default (and maybe a random from a list of defaults?)