首先在当前模板中的function.php中写入:
- function catch_that_image() {
- global $post, $posts;
- $first_img = '';
- ob_start();
- ob_end_clean();
- $output = preg_match_all('//i', $post->post_content, $matches);
- $first_img = $matches [1] [0];
- if(emptyempty($first_img)){ //Defines a default image
- $first_img = "/images/default.jpg";
- }
- return $first_img;
- }
然后在需要调用的地方写上.
新闻热点
疑难解答
图片精选