wordpress自动内链

Gavin Wu 2021年01月13日 11:01 Wordpress 1,184 Views

wordpress文章见容的关键词进行自动内链,方法如下。

1
2
3
4
5
6
7
8
9
10
11
//自动内链
function replace_text_wps($text){
$replace = array(
'微言心语' => '<a href="https://wuean.com/" rel="bookmark">微言心语</a>',
'个人网站' => '<a href="https://wuean.com/" rel="bookmark">个人网站</a>',
'个人博客' => '<a href="https://wuean.com/" rel="bookmark">个人博客</a>'
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}
add_filter('the_content', 'replace_text_wps');

就是在文章中遇到微言心语、个人网站、个人博客都链接到对应的链接

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Top