Lesson: How to make a static page your "home" page (44 posts)

  1. mrcoug
    Posted 10 years ago #

    Is there a conclusively best solution for making your home page static? I just want to suppress the default posting of everything to the home page.

  2. jpmcc
    Posted 10 years ago #

    A little example of how easy it is to set up a static home page in WordPress.

    Step One Create your home page like any other WordPress Page using using Write -> Write Page. Give the Page a post-slug of home. Test that it looks ok.

    Step Two You now need to create a special page which will be used whenever users access the home URL of your site. If you have a file called home.php in your current theme, WordPress will use this whenever users go to your home URL. So, if you are using the default WordPress theme, go to the wordpress/wp-content/themes/default directory, and copy index.php to home.php.

    Step Three You now need to change home.php so it only displays the home Page you created in Step One. Edit home.php using Presentation -> Theme Editor, and add in the second line below:

    <?php get_header(); ?>
    <?php query_posts(’pagename=home’) ?>

    This tells WordPress to only display the Page with the page-slug of home on this page. Don't forget to press Update File to save your new home.php.

    Now that wasn’t hard, was it? If you want to see what it looks like in practice, see for example http://www.balerno-communitycouncil.org.uk

  3. blockage
    Posted 10 years ago #

    jpmcc thanks, and yes it was easy.

    One thing, I now don't have a page with my posts on. I can access individual categories and archive pages. How would I create a page that has all my latest posts and dosen't appear to be an archive?

  4. dherren
    Posted 10 years ago #

    Denis de Benardy's solution is still MUCH MUCH easier with no editing of any files required:

    Step One: Install and activate Static Front


    Step Two: Name ANY page you want to become your home page 'home'

    The beauty is that you don't have to modify any files at all, WP will still use your home.php file automatically, you can have a bunch of pages that don't get displayed with alternate content and then make them the home page at will and change back, all within the admin interface of WP. No access to files is needed.

    I use this on some 20+ WP driven sites I run for high schools.

  5. cassady
    Posted 10 years ago #

    Okay I understand that part. But then I want to use my blog as well. these are Denis' intructions:

    FAQ: I want a static front page and a normal blog

    1. Use the static front page plugin normally
    2. Create a category called 'Blog', make it the default category, and put every post in it
    3. Link to the 'Blog' category in your navigation menu.

    I am using the blix theme and I have no idea how I should do step 3. I am a php newbie and this is driving me bananas.

    this is the navigation code from the header:

    <!-- navigation ................................. -->
    <div id="navigation">

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
    <input value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" />
    <input type="submit" value="Go!" id="searchbutton" name="searchbutton" />

      <li<?php if (is_home()) echo " class=\"selected\""; ?>>">Home
      $pages = BX_get_pages();
      if ($pages) {
      foreach ($pages as $page) {
      $page_id = $page->ID;
      $page_title = $page->post_title;
      $page_name = $page->post_name;
      if ($page_name == "archives") {
      (is_page($page_id) || is_archive() || is_search() || is_single())?$selected = ' class="selected"':$selected='';
      echo "<li".$selected.">Archives\n";
      elseif($page_name == "about") {
      (is_page($page_id))?$selected = ' class="selected"':$selected='';
      echo "<li".$selected.">About\n";
      elseif ($page_name == "contact") {
      (is_page($page_id))?$selected = ' class="selected"':$selected='';
      echo "<li".$selected.">Contact\n";
      elseif ($page_name == "about_short") {/*ignore*/}
      else {
      (is_page($page_id))?$selected = ' class="selected"':$selected='';
      echo "<li".$selected.">$page_title\n";

    </div><!-- /navigation -->

    Now I have two navigation buttons called HOME in my nav bar :(

  6. armchairanarchist
    Posted 10 years ago #

    OK people, this is confusing the living hell out of me. I'm no superfly coder by a long chalk, and the huge number of conflicting methods is making my brain hurt.

    Basically, I've been trying the method mentioned in the codex here:


    I got the static-frontpage plugin, installed it etc. I made a 'home' Page in WP, and then made a 'blog' Page with the blog template defined at the above link.

    When I set it all running with the plugin turned on, *both* the root address of 'mysite.co.uk/' and 'mysite.co.uk/blog/' display the 'home' Page I created.

    If I then turn the plugin off, both of those addresses show the normal wordpress blog layout (index.php, I'm assuming).

    Now the only thing I *think* I could be doing wrong here is not making a home.php file...that codex page says to make one, but doesn't tell me what it needs to contain. I tried using jpmcc's method above, and got blank pages when trying to view my site. dherren's method works, but you can only access the blog content via the archives...what I want is a home page at 'mysite.co.uk/', with links on it to my blog at 'mysite.co.uk/blog/' running as normal, and the possibilty of links to other static pages also.

    Is the lack of a 'home' template the problem, and if it is, what should go in it? Or is this data redundant with the new version of WP (the codex having no 'last updated' data to let me be able to guess)? Your advice would be appreciated...please note that the static-front plugin is currently off should you view my site (address in profile). I hope I've not come across as too ignorant, but I started learning php when I installed WP a week ago; I have searched through these forums, and this is the closest thread to answering my question, so I decided to post my question here. If I am in error to do so, please accept my apologies.


  7. lxg
    Posted 10 years ago #

    As for me, I don't like the sem-static-front. First, it is under a proprietary license, second I remember having had issues with it (though I have to admit I don't know anymore what it was).

    I have made very good experience with the Home Page Control plugin by Il Filosofo. Especially with WP 2.x it's worth a try.

  8. armchairanarchist
    Posted 10 years ago #

    Cheers mastermind, that works like a charm...only now the blog page has the sidebar displaced to underneath all the post data! I think I have an idea how to fix that though, using the 'blog.php' template from the Codex. I shall give it a try...thanks for replying, you're a star! ;-)

  9. lxg
    Posted 10 years ago #

    You're welcome. :)

    However, I can hardly imagine how the HPC plugin could affect the page layout. And on my browser (Konqi) the page seems to be alright at first glance.

  10. armchairanarchist
    Posted 10 years ago #

    Would you believe it, found a solution that involves no hacks or plugins deep in the codex, under a different topic:


    (scroll about 2/3 down the page to the 'Post & Page Parameters' heading)

    When I'm a bit more confident about messing with my templates, I'll give that a try...but I hope this discovery proves helpful to anyone else struggling to implement a static homepage with minimal messing about, hence me posting it in this thread.

    Thanks again for the help, mastermind. Peace...

  11. jhfarr
    Posted 10 years ago #

    Where in the name of God IS Ryan Boren's "Page to Front" plug-in??????

  12. jhfarr
    Posted 10 years ago #

    Oh wait, I think I see. Just the code is available, not the package. Looked everywhere for that sucker, and there it is at the front of this lesson.

    Uh, I think.

  13. wealthontap
    Posted 10 years ago #

    Hi guys,

    I used Root's solution which worked fine. I have one small issue that is really bugging me. I am using the blix theme and I have my pages in the top menu, the only way I can think of linking to my blog is by linking to a category, which in this instance is fine. However I can't get it to stay highlighted once it is selected like the pages do. If anyone knows what code to use I would be stoked.

    It's not a major but one of thos elittle things that will either sit there and bug you take hours and hours to solve.

    The site is http://www.davidlaw.co.nz

  14. coolrasta
    Posted 9 years ago #

    Thanks for this turotial...

Topic Closed

This topic has been closed to new replies.

About this Topic