Protecting a page with password in WordPress

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

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

Done!

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 zijn geschreven door Mathieu Scholtes, eigenaar van WPBeveiligen. Volg Mathieu op LinkedIn voor het laatste WordPress-nieuws, handige tips en exclusieve aanbiedingen.
Bezoeken op LinkedIn!

Deel jouw vraag, tip of mening!

Abonneer
Breng me op de hoogte
guest
0 Reacties
Inline Feedbacks
Bekijk alle reacties
Pak 20% korting met de combo deal!
▼ Nee nog niet