wordpress建站过程中,很多时候,我们的文章中没有设置特色图片,但是我们想显示出来这篇文章中的第一张图片,下面介绍一下方法:
1. 切换到你主题所在目录,打开function.PHP文件,加入下面这段代码:
注:此方法工作原理是查找文章内有没img这个标签,如果有就调出第一张图片,如果没有就用一张设计好的图片代替
Crayon-5c891d54ecb1c040905009" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">functions.PHP
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="Copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">
Crayon-nums " data-settings="show"> Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"> Crayon-num" data-line="Crayon-5c891d54ecb1c040905009-1">1 Crayon-num" data-line="Crayon-5c891d54ecb1c040905009-3">3 Crayon-num" data-line="Crayon-5c891d54ecb1c040905009-5">5 Crayon-num" data-line="Crayon-5c891d54ecb1c040905009-7">7 Crayon-num" data-line="Crayon-5c891d54ecb1c040905009-9">9 Crayon-num" data-line="Crayon-5c891d54ecb1c040905009-11">11 Crayon-num" data-line="Crayon-5c891d54ecb1c040905009-13">13 | Crayon-code">
Crayon-nums " data-settings="show"> | Crayon-code">