How to Password Protect a Section of WordPress Page Content

Password Protect WordPress (PPWP) enables you to protect not only the entire page but also partial content. It comes in handy when you want to show a part of content to engage the readers while hiding the rest for paid users.


In this article, we will walk you through the sections below:

How to password protect a section of content?

Simply wrap the section you need to protect with the shortcode below:

[ppwp passwords= "password1 password2"] Your content [/ppwp]

Classic Editor

Gutenberg Editor

Once done, click on Publish button and you will see something as below:

Our plugins support multiple passwords per shortcode by default. Users enter “password1” or “password2” to access your protected area.

Each password is case-sensitivity and no more than 100 characters, but doesn’t contain [, ], “, ‘ and space characters (as WordPress’ rule).

It’s important to note that “passwords” attribute is required. If not, you will see the error message: [ppwp] Empty content, invalid attributes or values instead of password form.

Features in brief

  • Support Pages & Posts (not Custom Post Types)
  • Support both Gutenberg & Classic Editor
  • Support multiple passwords per shortcode
    • Two passwords are separated by at least one space
  • Support multiple shortcodes per page
    • Users just enter passwords one time to unlock all content protected by the same password
  • Support cookies which allows users to access hidden sections in a period of time without re-entering password
    • Set the cookies time’s value under setting page
  • Support “Copy shortcode” button under setting page

Optional Attributes

We provide some attributes to customize the password form as well as protection type to suit each individual needs as below:

Whitelisted Roles

Any roles in whitelist don’t have to enter password to access the hidden section.

[ppwp passwords="password1 password2" whitelisted_roles="administrator, editor"]
Your protected content

Password Form

  • headline: Overwrite the default title “Restricted Content” of your password form:

[ppwp passwords="password1 password2" headline="custom headline"]
Your protected content

  • description: Overwrite the default description “To view this protected content, enter the password below:” of your password form:

[ppwp passwords="password1 password2" description="custom description"]
Your protected content

  • placeholder: Add placeholder to your password form:

[ppwp passwords="password1 password2" placeholder="custom placeholder"]
Your protected content

  • button: Overwrite the default button text “Enter” of your password form:

[ppwp passwords="password1 password2" button="custom button text"]
Your protected content

  • id & class: Allow you to apply a style to your password form and match your custom theme.

[ppwp id="custom-id" class="custom-class" passwords="password1 password2"]
Your protected content

Lasted updated on September 15, 2019