WordPress is an open source content management tool. It is written in PHP and MySQL. It is an easy platform to create beautiful sites. WordPress gives another set of powerful privacy feature which lets you create posts for a specific group of people or site editors. In this guide, we will look into different methods on how we can password protect a WordPress page or posts
Prerequisites
- A Domain name (example.com)
- WordPress admin credentials
Step 1:
Login to your WordPress admin dashboard. Click on Posts and Click on Add New to create a new post.

Step 2:
After writing your new post, you can select your privacy from the Publish menu on the right side of the admin panel.


Click on the Edit button in the Visibility section of the Publish window. On clicking the Edit button, you can select the Password Protected option and set a password to view this post.
Step 3:
After setting the password, when you try to access the post, you will be asked for the password.

The post title will still be visible among other posts or on your site archives. We will learn how to completely hide the post in the next step.
Step 4:
To completely hide the post, we will need to make some change to functions.php file of the active theme. The functions.phpis located inside the theme directory.
/home/sitename/public_html/wp-content/themes/themeName/functions.php
Here, themeName is the name of your theme. It varies according to the theme.
We will add some code to the .php file.
// Completely Hide protected posts
functionexclude_protected($where) {
global $wpdb;
return $where .= " AND {$wpdb->posts}.post_password = '' ";
}
// display protected posts
functionexclude_protected_action($query) {
if( !is_single() && !is_page() && !is_admin() ) {
add_filter( 'posts_where', 'exclude_protected' );
}
}Save the changes infunctions.phpfile. This will make your posts completely hidden. You need to share the post url and password if you want someone to view your post.
Conclusion:
In this guide, we learn how to password protect our WordPress posts. We can also password protect the entire WordPress site using third party plugins like SeedProd Coming Soon Pro.
Check out the top 3 WordPress hosting services:
- Do you need the best wordpress hosting? Check out for our recommendations by clicking here.


