13+年专注全栈开发,承接小程序开发,分销系统定制,网站建设、搬家、搭建,二次开发等一站服务,欢迎咨询
有时候我们需要替换文章的某些文字为其它文字,比如给特定的文字加上链接,利用 SEO 和用户体验。下边的代码即可实现这种功能:/** *WordPress 替换文章的某些文字 *https://www.codenet.cc/*/function Bing_content_str_replace($text){ $replace_words = array( //添加要替换的文本,格式:'要替换的' => '替换到的内容' 'adminbuy' => '<a href="https://www.codenet.cc">adminbuy.cn</a>', '魔客吧' => '<a href="https://www.codenet.cc">AB模版网</a>', 'functions.php' => '<a href="https://www.codenet.cc/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教程:替换文章的某些文字_
wordpress教程
栏目文章由:
源码庄整理发布,转载请注明来源。
来源地址:https://www.codenet.cc/article/details/272.html
本站资源未标注正版授权软件均为会员提供或网上搜集,版权归原作者所有,如需商业用途或转载请与原作者联系;
发布的文章及附件仅限用于学习和研究目的,请勿用于商业或违法用途!如有侵权,请及时联系我们!
《更多用户服务协议声明》