Protecting a page with password in WordPress

Protecting a page with password in WordPress
datum-geschreven 27 Feb 2024

WordPress has a built-in feature that allows you to protect pages and posts with a password. You can set a unique password for each page or post.

Step 1: In your page or post, click on “Visibility: Edit” in the publish block.

Set password WordPress

Step 2: Select “Password protected” and enter your desired password.

Set password

Step 3: Publish the changes.

Publish changes WordPress


After these steps, you will see a password field on the page or post where you have set it.

Protect WordPress page

Simple, right?

Hide more than just the content?

With this function, WordPress only protects the content that is loaded with wp_content(), but not the custom fields that you have programmed in a page template or extra content areas via the Secondary content plugin.

If you also want to hide these, you can add this code to the template to hide that info:

<?php if ( !post_password_required() ) { ?>
This will also be hidden now!
<?php } ?>

De meeste artikelen worden geschreven door Mathieu Scholtes, de eigenaar van WPBeveiligen. Op de hoogte blijven van het laatste WordPress nieuws? WordPress tips? WordPress aanbiedingen?
Connect dan op Linked-in!

Heb je een vraag? Tip of gedachte? Deel die!

Breng me op de hoogte
0 Reacties
Inline Feedbacks
Bekijk alle reacties