check if post is set to “password protected”

There’s two main ways:

  1. You can use the post_password_required() function. This function returns true if the post has a password and false if the post doesn’t have a password, but it also returns false if the post had a password but the user has entered it and unlocked the post.
  2. You can get the post object with $post = get_post() and then check empty( $post->post_password ). This will tell you whether a post has a password regardless of whether or not the password has been entered.