WordPress Check If Page Is Password Protected

//post id is optional
if(post_password_required($post_id)) {}
//or
if(!empty($post->post_password)){
 // do some stuff
}

Leave a Comment