首页 WordPress函数大全 get_the_post_thumbnail()

get_the_post_thumbnail()

2020-05-02 / 4851阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

get_the_post_thumbnail( int|WP_Post $post = null, string|array $size = 'post-thumbnail', string|array $attr = '' )

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.

参数

$post

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

Default value: null

$size

(string|array)
(Optional)
Image size to use. Accepts any valid image size, or an array of width and height values in pixels (in that order).

Default value: 'post-thumbnail'

$attr

(string|array)
(Optional)
Query string or array of attributes.

Default value: ''

返回

(string) The post thumbnail image tag.

大家谈论
    我的见解