wordpress自定义文章类型的登录可见

        前面写了特定页面的登录可见,但是,页面上所展示的一些特定文章,也是不能给爬虫爬到的,这就需要特定文章也弄成登录可见。我是通过插件实现的。

//加载内容
add_filter('the_content', 'denglvkejian');
//加载内容
function denglvkejian($content) {
    if (is_single()) {//文章结尾插入内容
        //$content = $content.get_option('uesdto-xiaozu'); 
        $posttype = get_post_type();
        if($posttype == "xiaoxi" or $posttype == "wendang" or $posttype == "ziliao" or $posttype == "huodong"){
            if(!is_user_logged_in()){header('Location: https://xiaozu.uesdto.com/wp-login.php?redirect_to='.esc_url( home_url( $_SERVER['REQUEST_URI'] )));exit;}
        }
    }  
 
    return $content;  
}
© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称常用语 夸夸
夸夸
还有吗!没看够!
表情代码图片

    暂无评论内容