WordPress | get_the_post_thumbnail() Function

The get_the_post_thumbnail() is a WordPress builtin function to retrieve the post thumbnail.

When a theme adds ‘post-thumbnail’ support, a special ‘post-thumbnail’ image size is registered, which differs from the ‘thumbnail’ image size managed via the Settings > Media screen.

When using the_post_thumbnail() or related functions, the ‘post-thumbnail’ image size is used by default, though a different size can be specified instead as needed.


Function definition:

get_the_post_thumbnail() function examples 1:

get_the_post_thumbnail() function examples 2:

Reference: https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts: