How to Password Protect Your WordPress Pages and Posts

How to Password Protect Your WordPress Pages and Posts

When we decide to put our content on the web, in the majority of cases we’re looking to attract the largest audience possible. The more popular we become, the greater the likelihood our business will thrive.

Sometimes though, we don’t want to let just anyone see what we shared, or at least not immediately. Maybe we want to test a new version of our website and allow access to only a handful of people. We could also be a musician looking to share some new tunes, but only with a selected audience. Or we could be an inventor with a stellar product we’ve not yet patented, so we want only people we trust to have access to that content.

We’ve already covered how you can make your posts and pages private. But if you want to let only certain people see those private pages and posts in WordPress, all you have to do is password protect them. Then, only those with the correct password will be able to access the hidden content.

How to Password Protect WordPress Page

The visibility of every post and page you create in WordPress is by default set to public. The process of changing it for both pages and posts is the same.

As you go to create a new page or a post, take a look at the right-hand side of the screen. Next to Visibility: Public there’s the option to Edit this setting. Click on it and this is what you’ll see.

Password protect the page or post

Now, to password protect the page or post, all you have to do is select the password protected option, enter your desired password in the designated field, and click OK.

Password protected option

In Gutenberg, these settings are also at the right side of the screen, under Document settings. Just click on Public, for additional options to appear.

Password protect in Gutenberg

From this moment on, whenever you want to access that page or post, you’ll have to enter the correct password in the password form to see the protected content.

Enter the password to see the content

You can also easily check which posts and pages are protected with a password. From your admin menu go to Pages/Posts > All Pages/All Posts. All password protected pages and posts will be clearly marked with the text: Password protected.

Password protected pages and posts
Qode WordPress Themes: Top Picks
Bridge WordPress Theme Banner

Creative Multi-Purpose WordPress Theme

Stockholm WordPress Theme

A Genuinely Multi-Concept Theme

Startit WordPress Theme

Fresh Startup Business Theme

Biagiott banneri

Beauty and Cosmetics Shop

How to Quickly Change the Visibility Status

To change the audience of your posts and pages, you don’t have to go into every post and page separately. You can modify the setting from the page/post list, by hovering over the post/page that you wish to protect with a password and then clicking on Quick Edit.

Quick edit page or post

All that’s left to do is to enter the password and then press the Update button (on the right side of the screen).

Enter the password and update

How to Hide Password Protected Posts from Your Website

Setting a password for some of your posts will certainly limit its audience, but that post will still appear in the post list, on the author’s page, in search results, etc. If you’d like to hide it altogether so that no one else can see it unless they have a direct URL to it, you have two options.

One is to install the WordPress Hide posts plugin. That way, before you publish a new post, you’ll see the Hide Posts option at the lower right side of the screen. Simply tick the boxes for the places where you don’t want your posts to show up.

WordPress Hide posts plugin

If you want to automatically hide all password protected posts from your website, you can achieve that through some custom coding. Paste the following code in the functions.php file of your theme, and all your password protected posts will be hidden from your site.

// Hide password-protected posts
function exclude_password_protected_posts($where) {
global $wpdb;
return $where .= " AND {$wpdb->posts}.post_password = '' ";
// Where to hide the password-protected posts
function exclude_password_protected_posts_action($query) {
if( !is_single() && !is_page() && !is_admin() ) {
add_filter( 'posts_where', 'exclude_password_protected_posts' );
// Action to queue the filter at the right time
add_action('pre_get_posts', 'exclude_password_protected_posts_action');


No matter the type of website you have, knowing how to password protect your WordPress pages and posts allows you to manage your content safely, restrict access to it and keep it secure from an unwanted audience. Even if you’re not an experienced developer, you can do it in mere minutes. This will ensure only a selected few have access to your work, before (or if) you decide to share it with the rest of the world.

Post your comment