function get_postthumb($this) {
preg_match_all( "/<[img|IMG].*?src=[\'|\"](.*?)[\'|\"].*?[\/]?>/", $this->content, $matches ); //通过正则式获取图片地址
if(isset($matches[1][0])){
$thumb = $matches[1][0];
}
return $thumb;
}我们直接丢到当前主题的Functions.php中,然后意图是将设置文章中的第一张图作为缩略图。
<img src="<?php echo get_postthumb($this); ?>">在需要的调用首图调用。