wordpress怎么使用外链图片作为文章缩略图

   2025-07-23 admin00100

思路:

1、要有一个确定图片地址的方法:文章中的第一张图片,或者使用自定义栏目增加一个自定义值。

2、在前台调用确定好的图片:采用函数的方法还是直接调用图片。

实现如下:

前提:

任何调用最好都是在LOOP循环中,这样可以轻松的使用$post值。

1、调用文章中的第一张图片:使用$post->post_content获得文章内容,然后用匹配的方法得到第一张图片的src值。

preg_match('/@@##@@/i',$post->post_content,$index_piclink);if(count($index_piclink)>=2)$image_src=$index_piclink[1];if(!strstr($image_src,'http://'))$image_src=false;
 
举报收藏 0打赏 0评论 0
 
更多>同类资讯
推荐图文
推荐资讯
点击排行
网站首页  |  关于我们  |  联系方式  |  用户协议  |  隐私政策  |  版权声明  |  网站地图  |  RSS订阅
Powered By DESTOON