I have the following code for my functions.php but it won't work how I want it to. I basically want it to hide the category unless the user is logged in, so basically redirect them to a login page
Code seems fine to me but wondering if there's any suggestions? I can't find ANY decent plugins to help me either
add_action( 'init', 'check_redirect_page' );
function check_redirect_page() {
if ( !is_user_logged_in() && !is_category( 177 ) ) {
wp_redirect( home_url( '/login' ) );
exit();
}
}