Outil de recherche WordPress pour les développeurs et auteurs de thèmes



get_the_post_thumbnail_url ›

Depuis4.4.0
Dépréciéen/a
get_the_post_thumbnail_url ( $post = null, $size = 'post-thumbnail' )
Paramètres: (2)
  • (int|WP_Post) $post Optional. Post ID or WP_Post object. Default is global `$post`.
    Requis: Non
    Défaut: null
  • (string|array) $size Optional. Registered image size to retrieve the source for or a flat array of height and width dimensions. Default 'post-thumbnail'.
    Requis: Non
    Défaut: 'post-thumbnail'
Retourne:
  • (string|false) Post thumbnail URL or false if no URL is available.
Défini(e) dans:
Codex:

Return the post thumbnail URL.



Source

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 );
}