您的位置:首页 > 其它

wordpress深度seo优化教程 – 新站高度集权优化方案

2013-12-12 22:12 676 查看
昨天小V写了一篇关于wordpress的canonical标签的文章,不知道大家有没有发现在百度知道的源代码截图中发现这么一段
<meta name="robots" content="noindex,follow" />
那么这段代码的作用是什么呢?据robotstxt.org官方网站解释,这段代码作用是屏蔽搜索引擎对本页面的收录但是允许抓取该页面上的链接。那么为什么百度知道的SEO工作人员会把这么一条meta标签写在页面上呢?经过小V的观察发现百度知道所有的动态链接页面上都会包含一条这样的meta标签,但是进入该页面的伪静态链接却不会出现该meta标签,那么这样看来百度知道官方的SEOER意图很明显啊,是为了减少不必要的收录,来集中网站的权重。
好了接下来说正题,不知道大家发现了没有,wordpress的分类目录的分页以及标签页的分页其实在搜索引擎中排名并不好,而且也没什么实质性内容,那么我们可以通过
<meta name="robots" content="noindex,follow" />
标签来进行屏蔽以达到减少不必要的收录集中网站权重的效果,实现方法,打开主题的头部文件(一般情况下为header.php)在其中添加以下代码:
<?php
if(is_home()) { ?>
<?php $paged = get_query_var('paged'); 
if ( $paged > 1 ) echo'<meta name="robots" content="noindex,follow" />'; ?>
<?php } ?>
<?php
if(is_category()) { ?>
<?php $paged = get_query_var('paged'); 
if ( $paged > 1 ) echo'<meta name="robots" content="noindex,follow" />'; ?>
<?php } ?>
<?php
if(is_tag()) { ?>
<?php $paged = get_query_var('paged'); 
if ( $paged > 1 ) echo'<meta name="robots" content="noindex,follow" />'; ?>
<?php }?>
做完了网站收录处理,接下来在用nofollow属性减少下页面权重流失集中内页权重,代码如下:
//阅读更多链接添加nofollow
add_filter('the_content_more_link','add_nofollow_to_link', 0); 
function add_nofollow_to_link($link) { 
return str_replace('<a', '<a rel="nofollow"', $link); 
} 
//标签云添加nofollow
add_filter('wp_tag_cloud', 'cis_nofollow_tag_cloud');
function cis_nofollow_tag_cloud($text) {
    return str_replace('<a href=', '<a rel="nofollow" href=',$text); 
}
//内容页tag链接添加nofollow
add_filter('the_tags', 'cis_nofollow_the_tag');
function cis_nofollow_the_tag($text) {
    return str_replace('rel="tag"', 'rel="tag nofollow"', $text);
}
//作者归档链接添加nofollow
add_filter('the_author_posts_link', 'cis_nofollow_the_author_posts_link');
function cis_nofollow_the_author_posts_link ($link) {
return str_replace('</a><a href=', '<a rel="nofollow" href=',$link); 
}
   
//访客评论链接添加nofollow
add_filter('comments_popup_link_attributes', 'cis_nofollow_comments_popup_link_attributes');
function cis_nofollow_comments_popup_link_attributes () {
echo 'rel="nofollow"';
}
以上代码加到functions.php文件即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: