Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
30 Million+
Websites using our plugins
20+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Password Protect a Page or Post in WordPress (2 Easy Ways)

Ever wanted to share a WordPress page with a client, give subscribers access to exclusive content, or prepare a page before launching it publicly?

You don’t need to build a membership site or install a complicated access-control system to do it. WordPress has built-in password protection that lets you restrict access to individual pages and posts in just a few clicks.

In this tutorial, I’ll show you two easy ways to password protect a page in WordPress. I’ll also explain how to fix a common problem: when a supposedly protected page is still visible to everyone.

How to Password Protect a Page or Post in WordPress

✏️ TL;DR: To lock a single page or post, use the built-in visibility settings directly inside the WordPress editor. If you prefer to lock your entire site, then use the free Password Protected plugin instead.

Here’s everything we’ll cover:

Method 1: Password-Protect a WordPress Page or Post

If you only need to protect a single page or post, then WordPress includes a built-in feature that handles this out of the box. Setup takes a few minutes and you don’t have to install or configure any additional software.

Step 1: Open the Page or Post Editor

In your WordPress dashboard, navigate to Pages or Posts and click Edit under the item you want to lock down.

Edit post button
Step 2: Enable Password Protection

In the right-hand settings panel, find the ‘Status’ section. By default, anything you publish is visible to anyone on the web.

Publishing option in the sidebar

Click the status shown next to it, which reads ‘Draft’ or ‘Published’ depending on whether the page is live yet.

Then, select Password Protected.

The Password Protect option

This reveals a text box where you can set your password.

Pick something easy for readers to remember, but difficult for outsiders to guess. Avoid obvious choices like ‘1234’ or ‘password.’

Use a secure password field
Step 3: Save or Update Your Page

Once everything looks good, click Publish or Update if the page is already live. WordPress applies the password straight away.

To test it, open the page link in an incognito or private browser window. You’ll see a simple form asking for the password before it shows your content:

Password-protected post on a live site

Method 2: Password-Protect Your Entire WordPress Site

Method 1 locks one page at a time, but it becomes impractical when you need to hide your entire site.

For that, I use the free Password Protected plugin. It places a single password screen in front of your whole site, so a visitor has to type the password before they can reach any page or post.

Step 1: Install the Free Password Protected Plugin

To start, install the free Password Protected plugin from WordPress.org. For step-by-step instructions, check out our guide on how to install a WordPress plugin.

When you first open the plugin, a prompt asks whether to share basic diagnostic data and receive updates. You can choose Allow & Continue or Skip. Skipping takes you directly to the settings screen without locking or limiting any features.

How to protect your WordPress pages and posts using a free plugin
Step 2: Turn On Protection and Set Your Site Password

In your dashboard, go to Password Protected » General to manage all your site locking settings.

At the top of the panel, find the Password Protected Status toggle and switch it on. This is the setting that puts the password screen in front of your entire site.

Password protect your WordPress blog or website

The Protected Permissions section lets you choose who skips the password screen.

Always check Allow Administrators so you can view your site while logged in. Unchecking it will not lock you out of your dashboard, but you’ll have to type the site password in your own browser before you can see the front end.

The remaining options grant access to specific groups:

  • Allow Logged In Users: Lets any registered user skip the password prompt. This works great if your clients already have accounts.
  • Allow RSS Feeds & Allow REST API: Allow RSS Feeds makes your feed readable without the password, so only check it if an email service needs your feed. Allow REST API only applies to visitors who are logged in.

Next, scroll down to the New Password fields. Enter your chosen password in the first box and confirm it in the second.

Be sure to save your password in a password manager or another secure place, because the settings screen won’t show it again once you save. If you do lose the password, you can sign into WordPress via your usual login page and then either set a new password or deactivate the plugin.

Finally, click Save Changes to apply protection across your entire site.

How to add a password to your WordPress website, blog, or online store
Step 3: Check the Password Screen in a Logged-Out Browser

Because you enabled Allow Administrators, your browser bypasses the password screen automatically. To check that password protection is working properly, open a private or incognito window and visit your homepage.

You should see the password screen rather than your regular content. Entering your password will give you access to the full site, confirming that everything is working as expected.

Keep in mind that this method does not protect media files. Direct links to images and PDFs bypass WordPress page settings, so anyone with the file URL can still see them. You’ll need to protect those files using a content protection plugin.

To make your site public at any point, go back to Password Protected » General and turn off the Password Protected Status toggle.

Why Your Password-Protected Page Is Not Working

If your page opens straight away without asking for a password, don’t worry. This is the single most common issue people run into, and it’s almost never caused by a broken setting.

Rule Out Caching Issues

Caching plugins deliver saved static copies of your site, which means you might just be looking at a page saved before you turned the lock on.

If you run a caching plugin, then it’s worth clearing its cache, along with any page caching your hosting company runs, and loading the page again in a private window before you go any further.

Your Browser Already Has the Password

When you enter the correct password, WordPress stores a cookie in your browser. This cookie tells your website that you’ve already been verified, so you can browse without re-typing the password on every page load.

Because that cookie stays active for 10 days, your site will open normally once you test the password. To you, the page looks unprotected but it’s locked for everybody else.

To check what real visitors see, test your URL inside a private or incognito window, which ignores existing browser cookies. If the password screen appears there, your setup is working properly.

If you used the Password Protected plugin, you can force-clear your access cookie. Simply add ?password-protected=logout to the end of your site address, and the plugin will log you out and return you to the lock screen.

The Password Is Case-Sensitive

This issue usually affects visitors rather than site owners. WordPress checks passwords using exact character matching, so it treats Spring2026 and spring2026 as completely different inputs.

An accidental space copied at the end of a string will also trigger an invalid password error.

Mobile keyboards make this error more common, as most devices capitalize the first letter of a text field automatically.

If a reader or client reports a password error, ask them to manually type the password in lowercase and check there are no extra trailing spaces.

The Title Still Shows on Your Blog and Category Pages

Even with protection active, your blog homepage, category pages, and search results still display the post title with a ‘Protected:’ prefix and its featured image. Those listing pages are what WordPress calls archive pages.

Depending on your theme, visitors will see either a password form or a quick notice stating the post is protected.

If revealing the title or image gives away confidential details, you can either edit the title or hide protected posts from those pages entirely using a code snippet.

Here’s the code snippet to remove password-protected posts from your main blog feed and archives, followed by the safest way to add it to your site:

function wpb_password_post_filter( $where = '' ) {
    if (!is_singular() && !is_admin()) {
        $where .= " AND post_password = ''";
    }
    return $where;
}
add_filter( 'posts_where', 'wpb_password_post_filter' );

This snippet tells WordPress to bypass password-protected posts whenever it builds your homepage or an archive page. The post remains fully accessible to anyone using its direct link and password.

You could paste this code straight into your theme’s functions.php file. I don’t recommend it, because a single typo in that file can break your site and lock you out of your own dashboard.

Instead, use a snippet plugin like the free WPCode plugin. WPCode keeps custom code separate from your theme files, so you can toggle snippets on and off from the dashboard. Your custom code will also survive when you update or change themes.

You can read our complete WPCode review for more information.

First, you need to install and activate WPCode. For step-by-step instructions, follow our guide on how to install a WordPress plugin.

In your WordPress dashboard, go to Code Snippets » Add Snippet. Hover over the ‘Add Your Custom Code (New Snippet)’ box and click ‘+ Add Custom Snippet’ when it appears.

Adding a custom snippet in WPCode

On the next screen, choose your code type by selecting PHP Snippet.

Choosing PHP snippet in WPCode

Start by giving your snippet a clear title, such as ‘Hide Password-Protected Posts,’ so you can identify it easily in your dashboard later.

Next, paste the PHP snippet into the Code Preview box:

Code preview for hiding password-protected posts

Finally, toggle the switch from Inactive to Active and click Save Snippet.

To check this worked, reload your homepage in a private browser window. The protected post’s title and thumbnail will no longer appear in your blog and category pages, while the post itself remains fully accessible via its direct address.

For more details, see our guide on how to hide password-protected posts from the WordPress loop. If you’d rather keep the post listed but show a teaser under the title, then we also have a guide on how to show the excerpt of a password-protected post.

FAQs: Password-Protect Pages and Posts in WordPress

Can visitors see password-protected content in search results?

WordPress keeps your locked content hidden from search engines out of the box. Google might index the page title and URL, but it can never crawl, view, or display the password-protected text inside.

If you want to prevent search engines from displaying the title or URL in search results entirely then you can set the page to ‘noindex’ using an SEO plugin. This tells search engines to leave it out of their results altogether.

We use All in One SEO (AIOSEO) on our own websites. It lets you noindex a specific page right from the post editor, so the page stays out of search results.

For a complete walkthrough of these features, check out our detailed AIOSEO review.

How do I make a page private on WordPress?

Private and Password Protected are two different settings within the ‘Status’ menu, and they solve different problems.

Private restricts the page exclusively to logged in site editors and administrators, removing the password field completely. This makes it ideal for internal team documents.

Meanwhile, setting a Password creates an entry screen so you can grant access to clients or readers who don’t have a user account on your site.

For a complete walkthrough, see our guide on how to create a private post in WordPress.

How do I make an entire WordPress site private?

The free Password Protected plugin makes your entire site private. It places a single password gate in front of your website, making it ideal for client previews or sites under development.

This approach works best as a temporary measure rather than a permanent solution, as every visitor shares the same credential, and you cannot track individual user activity.

If you need a permanently private site with unique user accounts, check out our guide on how to make your WordPress blog completely private.

Can I password protect a media file or PDF?

No, neither method protects standalone media files.

Both methods secure WordPress pages, but media items like images and PDFs have direct URLs that load files straight from your server. As a result, anyone who has the direct link can access these resources.

To protect individual media files, you’ll need to use a dedicated security solution. Our guide to the best WordPress content protection plugins covers these options.

What happens when someone enters the wrong password?

If a visitor enters a wrong password, WordPress simply reloads the page and displays a brief error message. There’s no limit to how many times someone can try, and no IP lockout mechanism. That keeps things simple, but it also means the feature only suits low-risk content.

However, if you are handling sensitive or confidential data, you should consider using stronger security measures like user-based access or login requirements.

How long do passwords stay active?

When a visitor enters the correct password, WordPress sets a browser cookie that grants access for 10 days. If your visitors report re-entering credentials earlier or later than expected, a theme or plugin has likely adjusted that timeout period.

Can I use the same password for multiple pages?

Yes, you can reuse the same password across multiple pages or posts. This is particularly useful when sharing a collection of draft or client-only pages.

Just keep in mind that anyone with the password can view all those pages or posts, so this approach is best suited for low-security content.

Will password protection work with my theme?

In most cases, yes. WordPress’s default password protection works with any well-coded theme and inherits its basic layout and styling.

Additional Resources: WordPress Page and Post Management

We hope this article helped you password-protect pages or posts in WordPress. Next up, you might want to check out our helpful guides on:

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

31 CommentsLeave a Reply

  1. Once enter the password in on the password-protected page and it displays the protected information, how can I log out again to see what the page looks like to non-logged-in visitors?
    Thank you

  2. I have set the Blog page to password protected. The site is juliananoreen.com.
    Saved.
    It still is visible! Had a friend test from a cell phone. Visible there too.
    Is there an additional setting that I am overlooking?
    I am expecting to see a message and password section but the test posts are completely visible.
    Thanks for your insights!
    N

    • Hi Noreen,

      The blog page is a place holder to display your WordPress blog posts. Unlike regular WordPress pages which show page content, this page shows your blog posts list. Normally, the WordPress password protect feature works on the content of a post or page. However, a blog page has no content of its own. This is why before the password protection can kick in, the blog posts get displayed.

      Admin

  3. I have password protected a pages (and children pages…not posts). I want it to prompt the user to reinsert the password when they leave the page…
    I saw that you can set the post_password_expires to 0 but where would I do it for a page?

  4. My password protection is not working. It keeps referring back to the password prompt. Yes i have the correct password. Any ideas?

  5. I made sometime ago a Password protected post, but I can’t remember the password.

    Can you help me with this ?

    thanks in advance

  6. Is there a way to change the default text to these password protected pages? I would like to leave a link in this text if it’s possible?

    Thanks,
    J

  7. Hi, I use password protection for a specific page. However, whenever I use the password to access the page, a pop-up window appears and wants my admin credentials. How can I make this issue disappear. That shouldn’t happen. I used passwort protection before and it worked fine, but now it doesn’t anymore.

  8. I have pages not posts that are password protected. Being pages i have no issue with them showing up in archives etc. I have them on my menu. I want only the main page not any of its children to show up in my custom menu until the user logs in. Is that possible?

  9. the default WP expiry of the login is 10 days!! That is not much use on a private computer. I found if I used this plugin ‘Protected Posts Logout Button’ and added the logout button to every page with the password it logged out of all of them when I clicked one. It also allows setting auto logout time/cookie expiry. So I set 30 minutes in case a user does not logout.

  10. Static page – I set visibility to “password” and set a password. Worked a treat for a few weeks. In the last couple of days when entering password page results to “Forbidden”. Password is correct. have disabled Plugins, activated default themes and still same result – cannot access password protected content.

    Any thoughts…

    Is this a server host issue or WP issue?

  11. I tried this and find the following error: when someone wants to use it, they fill in the password (on a page) and they are redirected to the captcha and directed to my wordpress login in. That should not be the case? I do not understand this.

  12. Hi, interesting – I’ve never seen this before (I don’t think!). …Will this be bad for SEO purposes? Can search engines still crunch the content?

  13. So this was pretty cool – it protects the page. I enter the correct password, and the page shows up fine. Now, when I Refresh the page, it still shows up. When does the password prompt come up again?

  14. I am unable to access the private blog from my iphone as it only allows me to type the password in capital letters, yet my password is all lowercase.
    Also any text entry like subscribe box is all in caps too.

    how can I resolve this apart from changing the password to all caps.

    thanks
    Justin

  15. I think it’s a great feature. How can I open the password protected Page with a Query String? So I can send a Link to my friends. Thanks for any ideas.

    Thomas

  16. Hello sir,
    i added a link in my site and i want that whenever anybody click on in there then by Clicking this link will bring up a password prompt, if user successfully enters password they are allowed to access a password-protected page.

    Thanks in advance

  17. This works great EXCEPT the post is still showing up in the “Latest Posts” widget. Any code change to fix that?

  18. is there any way to make it available to logged in users. By default even a logged in admin cannot see this password protected post.

    Is there any way we can make it available to all logged in users?

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.