Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm looking at the function and template references and I'm not seeing a way to test for whether a post is protected. Is there a theme function for (something like) is_password_protected()?

I'm already using add_filter( 'the_password_form', 'custom_password_form' ); to override the default form that shows up, but I want to customize some other aspects of the look when a post is password protected.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Yes there is. It's post_password_required:

Whether post requires password and correct password has been provided.

share|improve this answer
    
Doh! How'd I miss that? Thanks for speedy answer! –  artlung Feb 8 '11 at 16:57
    
You're welcome. It happens pretty often, you need these obvious functions and can't find them... That's when WP Answers comes in :P –  Fernando Briano Feb 8 '11 at 17:05

Should be done close to this:

<?php 
if ( have_posts() ) :

while ( have_posts() ) : 

    if ( post_password_required() ) :
        the_content();
    else :

    endif; // password

endwhile; 
else: 
?>
share|improve this answer

Your Answer

 
discard

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.