wordpress建站如何实现在全站的img
图片标签上自动添加alt
属性和title
属性!下面web建站小编给大家简单介绍一下具体实现代码!
找到当前主题函数模板functions.php中新增以下代码:
function image_alt_tag($content){ global $post;preg_match_all('/<img (.*?)/>/', $content, $images); if(!is_null($images)) {foreach($images[1] as $index => $value) {$new_img = str_replace('<img', '<img alt="'.get_the_title().'-'.get_bloginfo('name').'" title="'.get_the_title().'-'.get_bloginfo('name').'"', $images[0][$index]); $content = str_replace($images[0][$index], $new_img, $content);}} return $content; } add_filter('the_content', 'image_alt_tag', 99999);
wordpress建站如何快速提交和优化您的网站(IndexNow插件)?
标签: wordpress图片属性, wordpress技巧
上面是“wordpress如何实现img图片自动添加alt和title”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4393.html
workflows工作流
森林里有一个皮肤像抛光黑曜石的生物
一个漂亮的混血女孩ComfyUI工作流
穿着蘑菇帽的小蚂蚁探险家ComfyUI工作流
彩色雄鹰玉雕ComfyUI工作流
一个港口配备了小型船只、起重机、集装箱和码头
海中一头鲸鱼ComfyUI工作流
一只张大嘴巴露出锋利的牙齿正在咆哮的雪豹
在地铁站里一个迷茫的非主流姑娘
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!