网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > WordPress
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 114.238.4.59
Old 2010-08-30, 08:46 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default 为 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);
function nofollowReadMore($link) {
	return str_replace('class="more-link"', 'class="more-link" rel="nofollow"', $link);
}
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 12:29 PM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.