wordpress protect website with password 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: password required wp
//post id is optional
if(post_password_required($post_id)) {}
//or
if(!empty($post->post_password)){
// do some stuff
}