When we decide to put our content on the web, we aim in most cases to attract the widest possible audience. The more popular we are, the more likely our business will flourish.
Sometimes we don’t want to let anyone see, or at least see right away, the things we share. Maybe we want to test a new version of our website and only allow access to a handful of people. We can also be a musician who wants to share some new tunes, but only with a select audience. Or we could be an inventor with a great product that we haven’t patented yet, so we only want people we trust to access this content.
We’ve already covered how you can make your posts and pages private. But if you want to allow only certain people to see these 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?
Visibility of every post and page you create in WordPress public by default. The replacement process is the same for both pages and posts.
Look at the right side of the screen when going to create a new page or post. Beside Visibility: General has the option To organise this setting. Click on it and this is what you will see.
Now all you have to do to password protect the page or post choose password protected choice, enter the password you want in the specified area and Click OK.
In Gutenberg these settings are also on the right side of the screen. documentsettings. just click peoplefor additional options to appear.
From now on, whenever you want to access that page or post, you will need to enter the correct password in the password form to see the protected content.
You can also easily check which posts and pages are protected with a password. From your admin menu navigate to: Pages/Posts > All Pages/All Posts. All password protected pages and posts will be clearly marked with the text: Password protected.
How to Quickly Change Visibility Status
You don’t have to go to each post and page individually to change the audience for your posts and pages. You can change the setting from the page/post listHover over the post/page you want to password protect and then Quick edit.
All that needs to be done is to enter the password and then update Press the button (on the right side of the screen).
How Do You Hide Password Protected Posts From Your Website?
Setting a password for some of your posts will definitely limit its audience, but that post will appear in the post list, author’s page, search results, etc. will continue to appear. If you want to hide it completely so no one else can see it as long as they don’t have a direct URL they can see, you have two options.
One of these, WordPress Hide Posts plugin. This way, before publishing a new post Hide Posts The option is at the bottom right of the screen. Simply tick the boxes where you don’t want your posts to appear.
if you want auto hide all password protected posts from your website, you can achieve this with some custom coding. Paste the code below into your theme’s function.php file 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');
Solution
Whatever type of website you have, knowing how to password-protect your WordPress pages and posts will allow you to securely manage your content, restrict access, and keep it safe from an unwanted audience. Even if you are not an experienced developer, you can do this in minutes. This will ensure that only a select few have access to your work before you decide (or do) to share it with the rest of the world.
Support our work ❤️
If you enjoyed this article, consider leaving a tip to help us keep publishing great content.



























