There are a many ways to develop a website in WordPress, locally, on a sub-domain or on a staging server but these ways mean that you will eventually have to migrate the site to a the live url at some point and sync the database. Although very achievable it can be a pain in the proverbial, especially if you are using some plugins that don’t store data in the database. Yes, you can use a plugin to make a website non public and develop that way but there’s more than one way to skin a cat!
This method will allow you to create a holding page, create a user as a subscriber and give them access to the site as it would be seen on a public url without giving them access to the dashboard.
So first off you will need WordPress installed on the server and on the url you intend the site to go live on. You will also need a simple holding page build with simple html like so:
<!DOCTYPE HTML>
<html>
<head>
<title>New Website coming soon!</title>
</head>
<body>
<h1>Congratulations you've just redirected non logged in users to this holding page.</h1>
</body>
</html>
Save that file in your theme folder and call it ‘holdingpage.php’
Now you need to redirect any users coming to the site to this page. You can simply do that by either putting this code in your index.php, home.php file or a template file that you might be using as the front page for your wordpress site. With the following I’ve used a custom template that is being used as the front page set in the WordPress dashboard under Settings > Reading.
<?php
/* Template Name: Custom Page */
if ( !is_user_logged_in()) {
get_template_part('holdingpage');
exit(0);
}
get_header(); ?>
This will redirect any non logged in users to the page called holdingpage.php in the theme folder. Now you can start to develop your WordPress site without worrying your client is going to look unprofessional with an under developed site, and they will be happy because they’ve got a nice neat holding page. To stop spiders crawling the site just put a disallow on the root in a robot.txt file in the main directory of your website.
After sometime you will have your site well under development and perhaps you’ll want to show the client some progress. No problem, what you’ll need to do is set them up as a user for the site specifically as a subscriber but first you need to paste this in to your functions.php file:
//redirect subscribers to the home url
add_action( 'admin_init', 'custom_profile_redirect', 12 );
function custom_profile_redirect() {
global $current_user;
get_currentuserinfo();
if ($current_user->user_level == 0)
{
wp_redirect( home_url() ); exit;
}
}
This will redirect subscribers to the home url and because they are logged in not only will they bypass the dashboard they will also bypass the holding page conditional and load the theme as it would normally on a live site.
The next bit of code is optional but, by putting it in the function.php file it will hide the admin bar from the user – handy if you just want the user to see the site as it would look live.
// hide adminbar
if (!current_user_can('administrator')) :
show_admin_bar(false);
endif;
Once the user (subscriber) has logged in they will need to logout or they might never see their lovely holding page again! Now we wouldn’t want to cause any unnecessary panic would we! So, it’s worth putting a logout url and you can do that by dropping this in to your header or footer somewhere:
<?php echo wp_logout_url( home_url() ); ?>
There are other applications for this and this is just a simple “Developing a WordPress site on a live url” technique that you can use for your clients, any other ways would be useful to hear about so feel free to leave a comment.
Hi Elliott, I have to say I’ve never seen this method used before.
I would normally just build a normal holding page, and build WordPress in a new Directory then move out the index.php, and wp-config. Does this method have any benefits? I know it “could” be found but my directory normally has a random name that couldn’t be guessed.
I appreciate your opinion, it certainly seems a far more professional way to do things.
Lorraine.
Thanks for the feedback Lorraine.
– for live sites that are already running on a url I still have to develop in a similar way to you and have the agro of the re-syncing.
Although your directory is not public – spiders could technically still crawl and index your pages in Google without a block on that directory. The benefit of doing it this way for me is to cut out the hassle of re-syncing the database and correcting the permalinks no other reason really
This is just an attractive alternative that uses the wp core to login also, users can get familiar with the wp login process
Hi Elliott
Very interesting article, thanks for sharing. This is definitely the way I will try when developing my next WP site. So much cleaner than migrating the site and setting it up again.
Will
Thanks for your comment Will, it sure is easier.
I do think I had a site crawled recently in that way. I think I’ll give it try on a site I’m building locally at the moment. I guess that is where the real benefit is. I have been caught out showing a site to a client and the images are missing in places as to me they are still reading from my hard drive as I’ve missed a few links. I do check every site on the iPad now but you are right, it would save that whole issue altogether.
Thanks for sharing this Elliott.
You’re welcome.
I’m sure you already know this but, just make sure you disallow the root in the robot.txt and you should be fine:
User-agent: *
Disallow: /
Don’t forget to change to Allow: / once the site is live.
Hey,
Read your post and it’s pretty interesting. A nice and professional way to do things. Will perhaps try this in the future. Thanks for this, Elliot
You’re welcome Li and thanks for your comment
Hi,
For those that don’t want to get too techy or code files, this is a nice WP plugin to handle maintenance and can be used when you need to take the site offline in future.
http://wordpress.org/extend/plugins/cgc-maintenance-mode/screenshots/
Dan
Thanks for your comment Dan, very useful share.
Will definitely try this some day, I usually use the Maintenance Mode plugin though
Hey thanks for stopping by Todd.
Yup, I’ve used the Maintenance Mode plugin myself and it’s a very useful plugin but, when it comes to adding that little touch of branding I find the manual option better.
Agreed, the little credit in the corner can often be a bit sucky
but it’s dead easy to implement if you’re only showing a client amendments back and forth.
This is exactly the third posting, of yours I actually
went through. Nonetheless I personally love this 1,
“Developing a WordPress site on a live url” the most.
All the best -Melodee
I’m glad you’ve found this site useful Melodee.