当前位置:首页 >> 教程资讯 >> WordPress教程

WordPress教程:替换文章的某些文字

录入编辑:微科技 | 发布时间:2023-01-04
有时候我们需要替换文章的某些文字为其它文字,比如给特定的文字加上链接,利用 SEO 和用户体验。 下边的代码即可实现这种功能: /** *WordPress 替换文章的某些文字 *https

有时候我们需要替换文章的某些文字为其它文字,比如给特定的文字加上链接,利用 SEO 和用户体验。
下边的代码即可实现这种功能:
/**
    *WordPress 替换文章的某些文字
    *https://www.adminbuy.cn/
*/
function Bing_content_str_replace($text){
    $replace_words = array(
        //添加要替换的文本,格式:要替换的 => 替换到的内容
        adminbuy => <a href="http://www.adminbuy.cn">adminbuy.cn</a>,
        魔客吧 => <a href="http://www.adminbuy.cn">AB模版网</a>,
        functions.php => <a href="https://www.adminbuy.cn/wordpress/">functions.php</a>
    );
    return str_replace( array_keys( $replace_words ), $replace_words, $text );
}
add_filter( the_content, Bing_content_str_replace );
add_filter( the_excerpt, Bing_content_str_replace );

上一篇:WordPress教程:防止机器人扫描邮箱
下一篇:ecshop的SEO优化有什么好的建议
热门服务和内容

手机版

  • 官方微信

    扫码进入

  • 客服微信

  • 官方微信

    扫码添加

  • 高端网站设计,顶级互联网服务 Copyright © 2025 www.vikj.cn All Rights Reserved. 辽ICP备17005629号 XML地图 微科技
    电话咨询:0411-39550725
    在线客服咨询