Is there a theme function for is_password_protected()?

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.

Related posts

Leave a Reply

2 comments

  1. Should be done close to this:

    <?php 
    if ( have_posts() ) :
    
    while ( have_posts() ) : 
    
        if ( post_password_required() ) :
            the_content();
        else :
    
        endif; // password
    
    endwhile; 
    else: 
    ?>