How To Make WordPress Site Private

How To Make WordPress Site Private[3 Methods]

Last update on:

If you have a WordPress site, you may sometimes want to keep it private and limit access to only certain users. Maybe you want to keep certain content private for security or collaboration purposes, or maybe you just want to create a personal space for yourself.

Perhaps you’re working on a sensitive project and want to keep it hidden from the public until it’s ready to be launched. Regardless of your reason, it’s easy to make your WordPress site private.

By the end of this post, you’ll learn how to make a private WordPress site that only you (and any users you grant access to) can view.

Without further ado, let’s get into the action. Now, first, hide your site from search engines.

3 Ways to Make a WordPress Website Private

There are 3 ways to make a WordPress site private.

  • Using the default WordPress Settings
  • Using a plugin
  • Using the code (Advanced User)

We will walk you through all the methods with examples and screenshots (possibly) to help you understand what you need to do. You can start from the basic settings to the advanced feature as it fits your needs.

1) Make the Website Private with WordPress Default Settings

You can make your whole website or specific pages/posts private using default WordPress settings. To make any page or post private first click on Pages/Posts from the WordPress dashboard. 

WordPress page and post setting from dashboard

Now click on the “Edit” button under the page to launch the WordPress editor. 

edit option in the page setting

You can do it from the front end of the website as well. In that case, you have to visit the page/post you are trying to make private and click on the edit button above the header of your site.

edit page from wp header tool

Here you will see a “Summary Block” on the right-hand side. Click on that box to drop down other settings under that. 

summary block in wordpress editor

You will see a “Visibility” setting and if it says “Public” that means anyone can see your page/post. To make it private you need to click on the visibility setting and check other options.

If you want to make it private, select that option and click on update.

visibility setting on post sidebar

You might notice that only log-in user who has an editor or administrator privilege can see that page. So anyone below that level even with registration on the site won’t be able to access that page/post.

If you are wondering how it will look for the visitors it will return as a deleted page with your header, footer, and sidebar. 

how private page looks in visitors browser

This is a time consuming and not the best method of making your WordPress website. You can’t even hide the website completely. The site structure and links will be clickable except the viewing the content.

However, if you don’t want to add any plugins or just want some specific pages/posts to be hidden for some reason it is a doable method. 

2) Make Your WordPress Site Private with a Plugin

This is a fairly easy and comfortable way to make a site private. You can even customize how your site should look. However, we feel if you want to keep your site private for development purposes keeping it in maintenance mode is a better option.

We will keep our focus on only making the site private rather than having more customization. You need to install a plugin from the WordPress repository to make your whole website private within a few clicks.

Click on Plugins > Add new on the WP dashboard and you will land on the WP repository. Search for the keyword “My Private Site” without quotes. You should see the plugin on the top result.

my private site plugin in wp repository

Install and activate the plugin just like other plugins on your site. After activating the plugin, you should see another option in your WordPress dashboard’s right sidebar, “My Private Site.” 

How To Make WordPress Site Private[3 Methods] 1

Click on the option to set up making your site private. You will require to change settings on 3 tabs. “Site Privacy” “Landing Page” & “Home Page.” Let’s look at each setting individually.

Site Privacy

Here you have to click “Enable login privacy” and keep the compatibility to “Standard.” 

enable site privacy settings

Click on “Save Privacy Status” to save the settings.

Landing Page

You can direct the traffic where you want him to be after your site is private. You have options like 1. Staying on the same URL, 2. Redirect to Homepage, 3. Redirect to a custom page or land on the WP login page.

enable landing page settings

Choose the best option for your site and click “Save Landing Page” then follow the next steps.

Home Page

You can specify if you want your homepage to be accessible without login or not. Usually, if you want complete privacy we suggest not enabling this option. 

home page settings in my private site


After you save all the configuration, no matter which links a visitor clicks will be redirected to your specified page. In this case, it will go to the login page.

login redirection after making site private

3) Make the Site Private With Code

If you are an advanced user and don’t want to add another plugin to your WordPress site, you can use this method. 

Precautions: This method can break your site, so if you are planning to use this you must know what you are doing. We won’t be responsible for the consequences.

You can approach 2 ways for making the site private using code. Editing the function.php file or editing the .htaccess file.

Editing Theme Code

You can use the code directly on the main theme however we suggest using a child theme to be safe. The method works the same for both the main theme and the child theme. First Go to Appearance > Theme Editor from the dashboard.

Then, select theme function or function.php file. 

Now copy and paste the code on the bottom of that file of codes and click save.

Note- You can use any of the following codes.

function make_wordpress_site_private(){

  global $wp;

  if (!is_user_logged_in() && $GLOBALS[‘pagenow’] !== ‘wp-login.php’){

    wp_redirect(wp_login_url($wp -> request));




add_action(‘wp’, ‘make_wordpress_site_private’);

When you integrate this code, it directs visitors to log in. Visitors can then proceed to log in to the accounts you specified for them. 

If you want to make your website public again just follow the previous steps and just remove the code from that file.

Another Code:

You can use the following code for your theme funcation.php file

add_filter( 'pre_option_blog_public', '__return_zero' );

This code will change the blog_public option in the WordPress database to 0, which will make the site private.

Another Code:

To make the site private for logged-in users only, you can use the following code:

function wp_private() {
  if ( !is_user_logged_in() ) {
add_action('template_redirect', 'wp_private');

This code will redirect users who are not logged in to the login page when they try to access the site.

Edit .htaccess File

This will not work for everyone but if your site runs under the apache server then you are in luck. You need to edit your .htaccess file and add this snippet there.

order deny, allow
deny from all
allow from

Another code for using htaccess file

AuthType Basic
AuthName "Private Area"
AuthUserFile /path/to/.htpasswd
Require valid-user

This code will create a basic authentication prompt for users trying to access the site. They will need to enter a username and password to continue.

Remember to change that IP address to your real IP address, or you won’t even be able to access the site using the domain.

You can find your .htaccess file in the website’s root folder. You can use your cPanel or desktop app like Filezilla to access the root folder. 

Once you add this code to the .htaccess file it will return in 403 error if you visit it from any other IP than your real one. You can test this with a VPN. 

403 result after making site private


No matter what is the reason you want to make your site private this guide should help you. All of the above methods are tried and tested you can choose any of them you like.

Going with a plugin is the best option for all. However, you can use the codes if you are an advanced WordPress user. We should warn you again we are not responsible for anything unfortunate happening with your site after the process. 

What’s your Reaction?


  • Palash Talukder

    Palash Talukdar is a digital marketer & the founder of WP Basic Pro. He has been building and managing WordPress websites for 5+ years. He loves to write about WordPress, SEO, marketing, productivity, and web performance.

    View all posts
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Saeed Khosravi's Official Site