自动给文章内容加粗,利于seo
如何给文章某个关键词自动加粗,加<b> <strong><h>等标签呢,如果你是wordpress就很简单了,用以下方法就可以实现自动替换。
在这里云中客介绍3种方法
1,在functions.php里加入下面的代码
add_filter('the_content','ccyzk_content_strong'); function ccyzk_content_strong($content){ $content=str_replace('云中客','<b>云中客</b>',$content); return $content; } 2,依然在functions.php里加入下面的代码,第四行到第五行可以换上你需要的内容
function replace_text_wps($text){ $replace = array( // 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS' '云中客' => '<a href="vr.ccyzk.com">云中客</a>', '自动替换' => '<a href="
vr.ccyzk.com
">自动替换</a>', ); $text = str_replace(array_keys($replace), $replace, $text); return $text; } add_filter('the_content', 'replace_text_wps'); add_filter('the_excerpt', 'replace_text_wps'); 3,第三个方法就是用插件了,直接官方wp插件搜: Search & Replace 就可以了。使用也方便。
原创文章,转载时必须以链接形式注明本文来自云中客,本文固定链接:http://vr.ccyzk.com/280.htm