that thar welcome page

as a follow up to the bendy corners post the other day, I thought I should explain how I got my theme to display my welcome page on the main blog listing. Well, it’s actually quite simple, and requires the index.php of your theme to be modified with the following:

<?php $welcome = get_page_by_title('Welcome'); ?>
<?php if ($welcome && $welcome != '') { ?>
<div id="welcome">
<h2><?php print($welcome->post_title); ?></h2>
<?php print(wpautop($welcome->post_content)); ?>
</div>
<?php } ?>

What this does, is selects the “page” in wordpress’ database with the title “Welcome” (including the upper case W) and outputs it inside a div with a known id so that we can style it, using css, and play with it’s properties via javascript.

The advantage that this method has over the alternative of hard coding the welcome page into the theme file, is that you can very easily update the content of your welcome page at any time using the standard wordpress authoring techniques.

Join the conversation

1 Comment

  1. Another technique I sometimes use for home landing pages is to make use of home.php, so along with the above you could have:

     ______________________________________
    | Welcome   |   Latest Post Excerpts   |
    | Page      | (all posts -             |
    | Insert    | excluding News category) |
    |___________|                          |
    | Latest 3  |                          |
    | Excerpts  |                          |
    | From News |                          |
    | Category  |                          |
    |___________|__________________________|
    

    By using query_posts(), you can have several loops within 1 page.

    Another function I have used on several occasions is setup_postdata() (Mainly within custom page templates), this enables you to fetch a pages data from anywhere and use it as a real loop so WordPress does not return a 404.

Leave a comment

Leave a Reply

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

%d bloggers like this: