Warning: Undefined array key "night" in /www/wwwroot/dhaomu.com/wp-content/themes/b2/header.php on line 18

WordPress替换文章的某些文字

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

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

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

/**
    *WordPress 替换文章的某些文字
    *https://www.dhaomu.com/
*/
function Bing_content_str_replace($text){
    $replace_words = array(
        //添加要替换的文本,格式:'要替换的' => '替换到的内容'
        'dhaomu' => '<a href="http://www.dhaomu.com">dhaomu.com</a>',
        '浩沐资源网' => '<a href="http://www.dhaomu.com">浩沐资源网</a>',
        'functions.php' => '<a href="https://www.dhaomu.com/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' );
温馨提示:
1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:duhaomu@163.com,我们将第一时间处理!
2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。
3.所有资源仅限于参考和学习,版权归原作者所有,更多请阅读网站声明

给TA赞赏
共{{data.count}}人
人已赞赏
编程技巧

WordPress网站前台空白问题的解决方法

2023-3-10 0:00:00

编程技巧

C语言技术for遍历数组

2023-3-13 0:00:00

0 条回复 A文章作者 M管理员

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914
----《》
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索