how to edit password protected page wordpress code example
Example: 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