WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to hide the sidebar of my page when the page is password protected and the password has not yet been entered.

I've searched for a while and haven't found any condition I could use. Maybe get_post_status could help, but still, I wouldn't know when the user has entered the password and can see the full page.

share|improve this question
Please edit your question to clarify. Private posts are not the same thing as password-required posts. Which are you after? – Chip Bennett Mar 11 '14 at 16:14
Sorry, seems that when I wrote the article I was mixing up password required and private. Modified the question to make it easier to understand. – Fredy31 Mar 11 '14 at 17:08
up vote 4 down vote accepted

You're after post_password_required():

<?php if ( ! ( $post->post_password && post_password_required() ) ) get_sidebar() ?>
share|improve this answer
Or is_user_logged_in() for private posts. – Chip Bennett Mar 11 '14 at 16:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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