WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

If I create a post and set the visibility to "password protected", it still shows up on the front page and in the feeds. Is it possible to hide posts from general view altogether, but still allow quick access to some people without creating an account for them?

(This is in WP 3.0.4)

share|improve this question

Both the the_content() and the the_excerpt() template tags already account for password-protected posts, via the post_password_required() conditional. If you need to output content, or comments, etc. outside of the_content()/the_excerpt(), call the post_password_required() conditional directly.

For example, if you don't want the comments template to be output if the post is password-protected. you could do the following:

if ( ! post_password_required() && ( is_single() || ( is_page() && comments_open() ) ) ) {          
    comments_template( '', true );

Or, if you don't want to display the post at all if it is password-protected, you could do something like this, inside the Loop:

if ( post_password_required() ) {
} else {
    // Normal Loop Post output goes here
share|improve this answer

My very simple solution is to put something like this in your loop:

<?php if( post_password_required() ) continue; ?>

This just skip the password protected entry.

share|improve this answer
This is going to screw up your pagination. Eg. if a password protected post is one of your, let's say, 10 on a given page, the page will only contain 9 posts. – chrisguitarguy Dec 21 '11 at 1:38

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.