![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
#1
IP: 114.238.4.59
|
|||
|
|||
|
怎样为 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);
function nofollowReadMore($link) {
return str_replace('class="more-link"', 'class="more-link" rel="nofollow"', $link);
}
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Install WordPress on IIS | topvip | Blog(博客)/Wiki(维客)/RSS/Cms | 1 | 2010-01-25 08:31 PM |
| 让wordpress首页显示特殊页面(flash首页等) | yahoo | Blog(博客)/Wiki(维客)/RSS/Cms | 0 | 2009-02-25 06:58 AM |
| 备份wordpress数据库的七种方法 | car | WordPress | 0 | 2008-11-15 11:12 PM |
| wordpress 搜索引擎优化的二十条实用技巧 | car | 搜索引擎优化 | 0 | 2008-03-11 08:33 AM |
| WordPress 中文包 | sunshine | Blog(博客)/Wiki(维客)/RSS/Cms | 0 | 2007-03-12 10:16 AM |