• I would like a splash page for my blog, however I don’t want to do anything too complicated, but I was thinking, as I am making my own theme and as I read in the docs (i’m learning as I make the theme), wordpress looks for home.php first and not index.php so if home.php was the splash page would it work?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Yes, but not without some help from PHP.

    A thing to keep in mind about index.php is that it’s not just the ‘default’ page but the backup to all the primary theme templates. If a single post (single.php) or archive (archive.php) template doesn’t exist, index.php is used. This also means that index.php is bypassed when one of these templates are around.

    The same goes for home.php. You can set it up to act as something like a welcome document or directory to other sections of your site or whatever, but there’s no way to use it as a basic splash which then jumps to the index.

    A simple solution would be to place WordPress in a subdirectory and have a splash page (in the root of the site) direct one to this, but with a little PHP in home.php you can determine what should be displayed based on how a person arrives at it. First, start off home.php with the following:

    <?php
    if( (strpos($_SERVER['HTTP_REFERER'], get_bloginfo('home')) === false) && !$_SERVER['QUERY_STRING']) :
    ?>

    A little complicated, but what’s happening is the if statement is verifying a visitor has not been referred to the home page from a link on your site, and there have been no queries passed to the page. In summary it’s asking: Have you come here from somewhere else to my site’s main url?

    If the answer is yes, what follows is displayed, and that’s where you place all the content of your ‘splash’ page. After that, insert:

    <?php else : ?>

    This will now display anything following it when the conditions in the previous if statement are not met. Here’s where you place your theme’s index.php’s content, as it will act as your non-splash home page. Finally, close up the document with:

    <?php endif; ?>

    Note that the above is not to be considered an endorsement of splash pages.

    ;)

    It works great, thanks:)))

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Splash page?’ is closed to new replies.