how a page is password protected in wordpress code example
Example 1: password protected website wordpress
In Wordpress by default there is a option for adding password to the page, just
change the "status & visibility" option from public to password protected
Example 2: 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
}