Whenever we are doing any serious work on a client’s website, we like to make the website inaccessible to normal visitors. For any visitors who are not logged in, we like to display a pretty page that we have built using Divi.

To accomplish this, we use these three steps.

1. Create an Under Construction Page

Create a page named ‘Under Construction’ and save it, making sure the slug is ‘under-construction’.

Also, you’ll want to set the template (in the Page Attributes sidebar metabox) to Blank Page, which will eliminate the standard header and footer. That way you won’t have any menus displayed.

2. Add code to redirect non-logged in users to the Under Construction page.

Place this code in the functions.php file.

/* Restrict Access to Logged in Users */
function my_page_template_redirect() {
  if ( file_exists ( ABSPATH . '/.under_construction' ) ) {
    if( !is_page( 'under-construction' ) && !is_user_logged_in() ) {
      wp_redirect( home_url( '/under-construction/' ) );
add_action( 'template_redirect', 'my_page_template_redirect' );

3. Create an empty file named .under_construction in the main WordPress directory.

To restrict access to the website, create an empty file named .under_construction and place it in the main WordPress directory (where files like wp-login.php are located).

The presence of the .under_construction file activates the code.

When work is done, simply delete the .under_construction file and visitors will be free to visit any page.


The process is the same for all of our client’s sites. Before we start work, we create the .under_contruction file. When we are done, we delete it.

When we are building a new site for a clients on a new domain, we use a page like the one in the featured image here. But once the site is live, we use create a specially designed Under Construction page for them.

Yes. I know there are plugins that will do this, but this is clean, simple, and adds minimal code to our clients’ websites.

Join our email list

Join our email list

Join our mailing list to receive the latest tech tips from our team.

You have Successfully Subscribed!

Pin It on Pinterest

Share This