I know, splash pages are wrong, evil, and will probably bring about the downfall of society. But what if you need one anyway? Say, for example, you are preparing to launch a site based on wordpress but while you’re still putting it all together you don’t want visitors poking around. How can you create a static splash page to tell people that your site is coming soon (whatever that means?)
I found myself in just that situation recently. I looked around for a plugin to let me replace my index with a simple html document for a little while. I may write one yet, but for now a beautifully simple solution is doing the trick. Here’s what to do:
- Create a blank file in your theme directory and call it something like
splash.php. - Make it a page template by pasting in the following:
<?php /* Template Name: Splash Page */ ?>
- Write your static HTML. If you need to link to images or stylesheets, I suggest putting them in a subdirectory of your theme called something like
splash. You can then reference them in your HTML using a bit of code like<img src="<?php bloginfo('template_directory'); ?>/splash/image.jpg" alt="" />. Notice the php which finds your theme directory for you so your theme remains portable.
Create a blank page and set it to use the custom page template you’ve created. You’ll find it under the Page Attributes menu. As of WordPress 3.1 it’s on the right side of the admin and looks like this image.- Under Settings > Reading set the front page to use a static page and select the new page you’ve created. The index of your website will now be your page template with no dynamic content and no other theme files included. Easy-peasy.
Because you never called get_header(), get_sidebar(), or get_footer() you can now have a totally static splash page while you’re tweaking a theme, editing content, and doing your WordPress business in secret behind the scenes. If you still want to pull in some content from WordPress (like the title and page content) you can even grab the loop from your existing page.php and use it in your splash page.
