0
function wpse_41699_wp(){
    if( is_page('Login')||is_page('register')||is_page('Blog')||is_page('blog') ){
        return;
    }else{
        if(!is_user_logged_in()){
            $url = get_bloginfo('home').'/login';//ACW-login location need to be specified
            header('HTTP/1.1 403 Forbidden');
            header("Location: $url");
            exit;
        }
    }
}

In the function.php, I added above code, I used above code to disable user access to my site without login, but I want to make regular use able to access blog section which is a page named Blog. but I do not konw why still, I will be direct to login page, while register page is been successufully unblocked from been request to login.

Can anyone help me on this one?

Thanks!

  • Is your blog page designated as the posts page under Settings > Reading? – Milo Oct 12 '13 at 20:07
  • yes, I did. that is the page – Adam Oct 12 '13 at 20:16
1

When you designate a page as the posts page, is_page() will no longer be true for that page, as it is now the "Home Page". Use is_home() instead to test if the posts page is the current page.

  • 2
    It seems counter-intuitive, but when you set a static front page and posts page, what you'd think as your "home page" is the front page and can be tested via is_front_page(). only when you haven't set those options will your front page be both the home page and front page. – Milo Oct 12 '13 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.