为指定分类的所有链接添加nofollow属性,那你可以将下面的代码添加到主题的 functions.php 文件即可:
代码如下:
function nofollow_cat_posts($text) {
global $post;
if( in_category(1) ) { // 修改这里的分类ID
$text = stripslashes(wp_rel_nofollow($text));
}
return $text;
}
add_filter('the_content', 'nofollow_cat_posts');
global $post;
if( in_category(1) ) { // 修改这里的分类ID
$text = stripslashes(wp_rel_nofollow($text));
}
return $text;
}
add_filter('the_content', 'nofollow_cat_posts');
希望本文所述对大家的WordPress建站有所帮助。
标签:WordPress
相关阅读 >>
wordpress静态化首页及去除url中的index.html
wordpress在iis服务器上的伪静态设置方法(解决中文url无法访问问题)
更多相关阅读请进入《wordpress》频道 >>
相关推荐
评论
管理员已关闭评论功能...
- 欢迎访问木庄网络博客
- 可复制:代码框内的文字。
- 方法:Ctrl+C。