#独家
WordPress如何让文章指定的关键词自动添加内链

将以下代码添加到当前主题functions.php 文件保存

/* 文章指定关键词添加内链开始 - 模板团*/
function replace_text_wps($text){
        $replace = array(
                '模板团' => '<a href="https://www.mbtuan.com/" rel="external nofollow"  target="_blank" title="模板团">模板团</a>',
                'WordPress' => '<a href="https://www.mbtuan.com/college/wp" rel="external nofollow"  target="_blank" title="WordPress">WordPress</a>',
                '网站模板' => '<a href="https://www.mbtuan.com/template" rel="external nofollow"  target="_blank" title="网站模板">网站模板</a>'
        );
        $text = str_replace(array_keys($replace), $replace, $text);
        return $text;
}
add_filter('the_content', 'replace_text_wps');
收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (17)

模板 WordPress教程 WordPress如何让文章指定的关键词自动添加内链 https://cs.2hzd.cn/1528.html

一家有态度的精品资源分享平台

常见问题

相关文章