Conditional to test if post has password protection enabled

You could use

if(!empty($post->post_password)){
   // do some stuff
}

which is what the post_password_required() code does before checking the user’s credentials against the password itself.

Leave a Comment