卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章64334本站已运行4115

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

有时候我们须要替代文章的某些文字为其它文字,比如给特定的文字加上链接,利用 SEO 和用户体验。

下边的代码即可实现这种功能:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

/**

    *WordPress 替换文章的某些文字

    *https://www.11dz.cn/

*/

function Bing_content_str_replace($text){

    $replace_words = array(

        //添加要替换的文本,格式:'要替代的' => '替换至的内容'

        '大众资源网' => '大众资源网',

        '帝国cms' => '帝国cms',

        'functions.php' => 'functions.php'

    );

    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教程把页面设置为首页之后分页失效
下一篇: phpcms v9 wap手机门户站点取消浏览大图并加载原图的方法

相关推荐

留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏