Example of adding a simple password check to a WP page.

You’ll need to publish to a web server with PHP available to have it work.  A local preview will not work.

Go to protected page

Instructions:

Protected page

Create your protected page, and give it a name ending .php instead of .html

Alt-S to view the HTML source, and add this code to the very top, in the placeholder labelled “Page Preamble”.

<?php
  include ('login.php');
  if (!$password_ok) exit;
?>

Login form

Create a login form page.  Name it “login.php”.  Exclude it from navigation.

On the login form, name the password field “password”.  Set the submission type to “No action”.

Alt-S to view the HTML source, and add this code to the very top, in the placeholder labelled “Page Preamble”.  Change the password from ‘mypass’ to be whatever you want.

<?php
  $password_ok = false;
  if (!empty($_POST)) {
    $pw = $_POST['password'];
    if ($pw == 'mypass') {
      $password_ok = true;
      return;
    }
  }
?>