Password Protected WordPress Pages

3d Animation

To password protect a custom templated post or page in WordPress add the following code above and below your templated content. You’ll still need to make sure the page or post is password protected in WordPress. This code snippet enables templated and custom field elements to also be hidden.


<?php
       if ( post_password_required() ) {
              echo get_the_password_form();
       }
       else {
?>

Put the custom content here


<?php
       }
?>