WordPress SEO 技巧:内链优化

最近在做一个新网站,Google 刚开始收录的时候发现归档页面的排名比文章还高,猜测原因是归档页面获得的内链太多了,因此产生一个把所有的指向归档页面的链接全部加上 rel=”nofollow” 属性的想法。要达到这个目的,我们完全可以用 WordPress 强大的 filter 来实现。打开主题的 functions.php ,在里面加上以下的代码: //给标签云里的链接加上 rel="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); }   //给 the_tags() 生成的链接 加上 rel="nofollow" add_filter(‘the_tags’, ‘cis_nofollow_the_tag’); function cis_nofollow_the_tag($text) { return str_replace(‘rel="tag"’, ‘rel="tag nofollow"’, $text); }   //给 wp_list_categories() 生成的链接加上 rel="nofollow" add_filter( ‘wp_list_categories’, ‘cis_nofollow_wp_list_categories’ ); function cis_nofollow_wp_list_categories( $text ) {   $text = stripslashes($text); $text = preg_replace_callback(‘|<a (.+?)>|i’, ‘wp_rel_nofollow_callback’, $text); return $text; }   //给 the_category() 生成的链接加上 rel="nofollow" add_filter( ‘the_category’, ‘cis_nofollow_the_category’ ); function cis_nofollow_the_category( $text ) {   $text = str_replace(‘rel="category tag"’, "", $text); $text = cis_nofollow_wp_list_categories($text); return $text; }   //给 the_author_post_link 生成的链接加上 rel="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); }   //给 comments_popup_link_attributes() 生成的链接加上 rel="nofollow" add_filter(‘comments_popup_link_attributes’, ‘cis_nofollow_comments_popup_link_attributes’); function cis_nofollow_comments_popup_link_attributes () { echo ‘ rel="nofollow"'; } 上面的 filter 针对的都是主题开发时一些使用率比较高的函数,基本上已经能满足我的要求了。快速域名备案 网站备案 域名备案  备案ICP代办 备案方法 备案流程 备案时间 备案查询 备案域名 个人企业备案 快速备案 代理备案 代办网站ICP快速备案 域名个人企业备案办理 办理icp备案方法流程 icp域名备案时间 域名快速备案网站查询 ICP网站备案地址办理网站备案,域名代备案,ICP备案,网站怎么备案,为什么备案个人企业域名备案 快速ICP代办办理 域名网站备案 快速域名ICP  代办网站备案专业代办ICP域名备案 证书网站备案 ICP办理许可证 网站快速备案 域名快速备案

本文出自快速备案,转载时请注明出处及相应链接。

本文永久链接: https://kuaisubeian.cc/4482.html

kuaisubeian