发布时间:2020-09-17
WordPress 常用函数 / get_the_post_thumbnail,
获取当前日志的缩略图(Post Thumbnail)。
<?php echo get_the_post_thumbnail( $post_id, $size, $attr ); ?>
$post_id
(integer) (Optional) 日志 ID。
Default: 当前日志 ID
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
$size
(string/array) (Optional) 图片大小,可以是以下几个关键字:thumbnail, medium, large, full,或者通过函数 自定义尺寸的关键字。或者宽和高的一个大小,比如:(32,32).
Default: ‘post-thumbnail’,当前主题通过函数 设置的。
PLEASE NOTE: The crop does not work in WP 3.0+. All that is needed for WP 3.0+ is the call for the thumbnail to post. Then proceed to media in the dashboard and set your thumbnail to crop to the size you wish to use.
$attr
(array) (Optional) 属性/值的一个数组,the_post_thumbnail 传递给函数 用来获取图。
Default: None
$default_attr = array(
'src' => $src,
'class' => "attachment-$size",
'alt' => trim(strip_tags( $wp_postmeta->_wp_attachment_image_alt )),
'title' => trim(strip_tags( $attachment->post_title )),
);
(string)
返回缩略图的 HTML 代码。
Since 2.9.0
wp-includes/post-thumbnail-template.php
全站搜索