Password Protect a WordPress Page
To password protect a WordPress page, open it in the editor, set its visibility to Password protected, type a password and click Update. Logged-out visitors then see only the title and a password form. One password covers everyone, the unlock cookie lasts 10 days, and media files stay publicly reachable.
For site owners sharing a client preview, a draft or a staging site without creating user accounts.
knowledge
- Read time
- 4 min
- Sections
- 7
- Updated
- 14 Nov 2026
- Written by
- WebJi® team
Last editorial update: 14 November 2026.
How to password protect a WordPress page in the editor
Open the page, change its visibility to Password protected, type a password and click Update; WordPress then shows a password form instead of the page body to every logged-out visitor. The feature is built into core, so no plugin is needed, and it works the same way for posts.
- Go to Pages → All Pages and open the page you want to lock.
- In the block editor's right-hand Page settings, open the Summary panel and click the status or visibility value. Recent versions show a Password protected checkbox in the Status popover; older versions and the Classic Editor show Visibility: Public → Edit in the Publish box.
- Select Password protected, type the password and confirm.
- Click Update (or Publish for a new page).
- Open the page URL in a private window while logged out. It has worked when you see the title and a password form, and the content appears only after the password is entered.
Each page has its own password, so two locked pages can use two different ones. Pick a password you do not use anywhere else; the WebJi® password generator creates one in a click.
What visitors see on a password-protected WordPress page
Visitors see the page title, usually prefixed with “Protected:”, and a password field; the content, excerpt and comments stay hidden until the correct password is entered. After that, a browser cookie keeps the page unlocked.
| Part of the page | Before the password | After the password |
|---|---|---|
| Title | Shown, with “Protected:” in front in most themes | Shown |
| Content and excerpt | Replaced by the password form | Shown |
| Comments | Hidden | Shown, if comments are open |
| Images and PDFs in the media library | Still reachable at their direct URL | Reachable |
| Logged-in Editors and Administrators | See the content in the editor without needing the password | |
The unlock cookie lasts 10 days by default, so a returning visitor is not asked again within that time. Changing the password invalidates every existing cookie at once.
How secure is the built-in WordPress page password?
It is a curtain, not a lock: fine for a client preview, a draft price list or a pre-launch page, but not for confidential documents. The password itself is stored in plain text in the post_password column of the posts table, so anyone with database access or a backup can read it.
- One password for everyone: no usernames, so you cannot revoke access for one person without changing it for all.
- No file protection: attachments in
wp-content/uploadskeep public URLs. Do not upload genuinely private files to the media library. - Other admins can read it: every Editor and Administrator sees protected pages in the editor, with or without the password.
- Search engines: crawlers receive only the password form, so the content is not indexed, but a page indexed before you locked it can show an old snippet for a while.
Password protected vs Private vs user accounts
Use Password protected to share a page with people who have no login, Private to hide it from everyone except Editors and Administrators, and real user accounts or a membership plugin when each person needs separate access.
| Option | Who can read it | Per-person access | Best for |
|---|---|---|---|
| Password protected | Anyone with the password | No | Client previews, short-term sharing |
| Private | Logged-in Editors and Administrators only | By role | Internal notes, unfinished pages |
| Role-based password plugin | Holders of one of several passwords | Partly | Two or three groups, such as staff and partners |
| Membership plugin with accounts | Logged-in members | Yes | Courses, paid content, client portals |
A Private page is not shown to Subscribers or Authors, so it is not a members' area. How roles differ is explained in WordPress user roles, and portal options are compared in best WordPress membership plugins.
How to password protect the whole WordPress site
To lock an entire staging or pre-launch site, protect it at server level with HTTP Basic Authentication, which prompts for a username and password before WordPress, images or wp-admin load at all. A site-wide plugin is the alternative, but it cannot protect static files.
On cPanel, Directory Privacy sets this up for the document root without editing files. On any Apache or LiteSpeed host, create the password file outside the web root and add a block to .htaccess:
htpasswd -c /home/USERNAME/.htpasswds/staging.htpasswd client
AuthType Basic
AuthName "Staging site"
AuthUserFile /home/USERNAME/.htpasswds/staging.htpasswd
Require valid-user
Replace USERNAME with your account name; -c creates the file, so leave it off when adding a second user. Basic Authentication sends credentials with every request, so use it only over HTTPS. Uptime monitors, payment webhooks and external cron calls will now be refused too; exclude those paths or pause them. The full staging workflow is in how to create a WordPress staging site, and the file itself is explained in the .htaccess guide.
How to change the password cookie lifetime or the form text
Two core filters control the behaviour: post_password_expires sets how long the unlock cookie lasts, and the_password_form replaces the form's HTML. Add them in a small site plugin or a child theme's functions.php.
// Ask for the password again after one day instead of ten.
add_filter( 'post_password_expires', function () {
return time() + DAY_IN_SECONDS;
} );
Return 0 instead to make it a session cookie that ends when the browser closes. To change the message above the field, filter the_password_form and return your own form markup, keeping the field name post_password and the form action pointing at wp-login.php?action=postpass.
Why a password-protected WordPress page opens without a prompt
Almost always because you are logged in as an Editor or Administrator, a cache is serving an unlocked copy, or a plugin has replaced the core check. Work through these in order.
- Test in a private window while logged out; editors never see the form.
- Purge the page cache and any CDN copy, then retest. Exclude protected URLs from full-page caching so an unlocked copy is never stored; the steps for common caching plugins are in how to clear WordPress cache.
- Remove any 10-day unlock cookie by testing in a fresh browser profile.
- Deactivate security, membership and page-builder plugins one at a time on a staging copy to find one that bypasses the form.
Every step works on standard WordPress hosting. If the live site behaves differently from staging, email support@webji.services with the URL and whether a CDN sits in front.
Frequently asked questions
Can I give each visitor a different password for the same page?
Not with the built-in feature, which stores one password per page. A role-based password plugin can issue a few separate passwords, and a membership plugin gives each person their own login that you can revoke individually.
Can I password protect a WooCommerce product or category?
A single product can be set to Password protected like any post, which hides its description. It does not reliably hide the product from shop listings, search or the cart, so private wholesale catalogues need a dedicated plugin or customer accounts.
Will password protecting a page affect SEO?
Search engines see only the title and password form, so the content will not rank. That is intended for private pages. If the page was public before, request removal of the old URL in Search Console and keep it out of your XML sitemap.
How do I remove the password from a WordPress page?
Open the page, change visibility back to Public (or untick Password protected) and click Update. The page becomes visible to everyone immediately; purge the cache so visitors do not keep getting the old form.
Checked 14 November 2026 against WordPress.org documentation · Reviewed by the WebJi® team, Jaipur.
Ready to get started with WebJi®?
Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.