![]() |
为 WordPress 的 Read more 加上 nofollow
怎样为 Read more 加上 rel="nofollow" 属性?
我不写出实现方法是有原因的. 1. 实现方法简单 2. 实现方法很多 3. 我的实现方法比较粗暴 不管如何, 既然这么多人感兴趣, 我就提出来说说吧. 以下我列举三种实现方法. 1. 打开 {WordPress 根目录}/wp-includes/post-template.php 文件, 然后在 get_the_content 方法里为 Read more 链接加上 rel="nofollow". 2. 在主题目录的 function.php 文件里重写 the_content 或者 get_the_content 方法. 3. 用 PHP 截取 the_content 输出的文本, 加上 nofollow 属性后再输出文本. 其中方法 2 和方法 3 可做成插件实现. 方法 1 简单方便, 而且效率最高, 所以我直接改了 WordPress 的源代码. 至于你选择哪种, 那只能由你自己判断了. 建议不明白真相的观众阅读我的上一篇文章, 在本站搜索栏搜索 "WordPress SEO" 既可找到. 实现代码,可以将以下代码加到 function.php 中实现在 read more 链接上添加 nofollow. Code:
add_filter('the_content_more_link','nofollowReadMore' ,0); |
| All times are GMT +8. The time now is 03:26 PM. |
Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.