-
Source code: details
ob_start(); function yincangwenzhang( $query ) { $delete_cat_yc=array('-72','-4','-5');// The upper and lower numbers should always represent your classified ID $delete_cat=array('72','4','5'); if(! is_user_logged_in()){ //Jump 404 when the user is not logged in to visit the article page if(is_single()&&in_category($delete_cat)){ wp_safe_redirect(home_url().'/ 404'); exit; } //Hide articles on the home page and other pages //$query->is_home()||$query->is_search()||$query->is_archive() //The uplink code works the same way, but I don't know why the articles on the author's page are not hidden, and it is useless to have parameters, so use the following If (get_current_user_id()==0) {//The user's unlisted ID is 0, and the article is hidden $query->set( 'cat', $delete_cat_yc); } }return $query; } add_filter( 'pre_get_posts', 'yincangwenzhang' );