
前面写了特定页面的登录可见,但是,页面上所展示的一些特定文章,也是不能给爬虫爬到的,这就需要特定文章也弄成登录可见。我是通过插件实现的。
//加载内容 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; }
还没有评论,来说两句吧...