Password Protecting Custom WordPress Templates

White logo on a gradient blue to purple background, featuring a stylized leaf incorporated into a square with rounded edges.

When creating custom WordPress templates, there are some instances where you do not want to add code, text, etc., in the WordPress content area. If you wanted to hide what was on your page, normally you would just use “Password Protect”.

A screenshot of a visibility setting menu with options: Public, Password protected (selected), and Private. Below the selection is a field to enter a password, followed by OK and Cancel buttons—ideal for password protecting custom WordPress templates.

When using “Password Protect” in WordPress, only the content area is password protected by default.

However, to choose what you want to password protect, we can update the template like so.

Screenshot of a PHP code snippet displaying a loop for posts and checking if password protection is required. If so, a password form appears; otherwise, it shows a custom area. Perfect for those creating custom WordPress templates.

Essentially when the page loads, the code will check whether the password has been entered or not. If it has not been entered, the form will show; otherwise, the code or whatever you wanted to hide will be displayed.

How to Update Default Password Protected Text in WordPress

WordPress gives you a generic form with text when adding the password-protected area. There are a few ways to update the area, but If you wanted a quick and easy way, add these few lines of jQuery.

A piece of JavaScript code that generates a password-protected form with the message: "This page is password protected. To view it, please enter your password below." Ideal for Password Protecting Custom WordPress Templates.

This essentially targets the first p tag (using the snippet of code above with the container div) that the default WordPress password protected text displays. You can style the text as you please by adding a span tag, etc.

Image showing a webpage that is password protected. Text reads: "This page is password protected. To view it please enter your password below." The form fields are indicative of custom WordPress templates, featuring a field for password entry and an "Enter" button.

This is a simple and easy way to update a template and adjust the password-protected area. If you need help creating a new site or updating your current website, contact PaperStreet Web Design.


Share This

Join the Sales and Marketing News, receive our last insights, tips and best practices.

Our 7 Guarantees

Keeping 2,000+ Clients Happy Since 2001.

You Will Love Your Design We design to please you and your clients
Same-Day Support 24-hour turnaround edits during business hours
Free Education We provide knowledge to help you expand
No Hidden Charges We quote flat-rate projects
Own Your Site No strings attached
We Create Results SEO, PPC, content + design = clients
We Make Life Easier One agency for web, branding and marketing