get_the_post_thumbnail_url( int|WP_Post $post = null, string|int[] $size = 'post-thumbnail' )

Return the post thumbnail URL.

Parameters

$post

(int|WP_Post) (Optional) Post ID or WP_Post object. Default is global $post.

Default value: null

$size

(string|int[]) (Optional) Registered image size to retrieve the source for or a flat array of height and width dimensions.

Default value: 'post-thumbnail'

Return

(string|false) Post thumbnail URL or false if no image is available. If $size does not match any registered image size, the original image URL will be returned.

Source

File: wp-includes/post-thumbnail-template.php

function get_the_post_thumbnail_url( $post = null, $size = 'post-thumbnail' ) {
	$post_thumbnail_id = get_post_thumbnail_id( $post );

	if ( ! $post_thumbnail_id ) {
		return false;
	}

	return wp_get_attachment_image_url( $post_thumbnail_id, $size );
}

Changelog

Version Description
4.4.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url