为指定分类的所有链接添加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添加html5的表单验证required方法小结
wordpress中is_sticky()判断文章是否置顶的参数与用法
关于wordpress的seo优化相关的一些php页面脚本技巧
更多相关阅读请进入《wordpress》频道 >>
相关推荐
评论
管理员已关闭评论功能...
- 欢迎访问木庄网络博客
- 可复制:代码框内的文字。
- 方法:Ctrl+C。