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

作者头像
6G站长网 本文作者

2026-4-16 阅读 1 约 4分钟读完

评论0

还在找WordPress教程替换文章的某些文字的靠谱教程?6G 站长网今天整理了WordPress教程替换文章的某些文字从入门到精通的完整指南,解决大家在学习WordPress教程替换文章的某些文字时 “步骤看不懂、操作易出错、效果不理想” 的核心问题,手把手教你做好WordPress教程替换文章的某些文字,新手也能一次学会。

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

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

/**

    *WordPress 替换文章的某些文字

    *https://www.x6g.net/

*/

function Bing_content_str_replace($text){

    $replace_words = array(

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

        '我的站长站' => '<a href="http://www.x6g.net">我的站长站</a>',

        '帝国cms' => '<a href="http://www.x6g.net">帝国cms</a>',

        'functions.php' => '<a href="https://www.x6g.net/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' );


上一篇 漫画屋-漫画大全-免费漫画在线看-最好看的漫画 下一篇 快看漫画
评论
评论已关闭