<?php
$args = array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image' );
$images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent=' . $post->ID );
$imageUrl = '';
if ($images) {
$image = array_pop($images);
$imageSrc = wp_get_attachment_image_src($image->ID);
$imageUrl = $imageSrc[0];
$imageWidth = $imageSrc[1]; //缩略图宽度
$imageHeight = $imageSrc[2]; //缩略图高度
?>
<img src="<?php echo $imageUrl; ?>" width="<?php echo $imageWidth; ?>" height="<?php echo $imageHeight; ?>">
参考资料:http://codex.wordpress.org.cn/Function_Reference/wp_get_attachment_image_src
声明:本文采用 BY-NC-SA 协议进行授权,如无注明均为原创,转载请注明转自 你好!刘
本文地址:调用WordPress自带缩略图设置
本文地址:调用WordPress自带缩略图设置
发表评论