为 WordPress 的 Read more 加上 nofollow
为什么要为 WordPress 的 Read more 加上 nofollo ?
因为 Read more 链接的路径实际和文章标题相同, 没必要再多加一个文本与页面内容无关的链接. 再者, "Read more..." 在网站出现 N 多次, 可能会干扰爬虫.
三种实现方法
1. 打开 {WordPress 根目录}/wp-includes/post-template.php 文件, 然后搜索 more-link,在这个标签里面为 Read more 链接加上 rel="nofollow".
2.用 the_content('') 进行文章截取,这时候不会显示 more 链接,然后用
<a href="<?php the_permalink() ?>" class="more-link" rel="nofollow">Read more...</a>
获取文章链接.
3.the_content_more_link (PHP 的字符串替换),把以下代码添加到你主题的 functions.php 文件中.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?php /*添加过滤器*/ add_filter('the_content_more_link','nofollowReadMore' ,0); /** * 用替换的办法把给 Read More 连接 * 添加 nofollow * * @param String $link * @return String */ function nofollowReadMore($link) { return str_replace('class="more-link"', 'class="more-link" rel="nofollow"', $link); } ?> |
方法收集于:mg12:为 WordPress 的 Read more 加上 nofollow
声明: 本文采用 BY-NC-SA 协议进行授权. 转载请注明转自: 为 WordPress 的 Read more 加上 nofollow
评论 (0)
Trackbacks (0)
发表评论
Trackback
最新评论Recent Comments