WordPress.org

Support

Support » How-To and Troubleshooting » Lesson: How to make a static page your “home” page

Lesson: How to make a static page your “home” page

  • Alright, I figured I’d make this a lesson post since I’ve seen a few people wanting to do this. This are the steps that need to be taken if you want to have a wordpress “page” your home page before people can see your blog.

    1. First step is to create a plugin with Ryan’s plugin:


    <?php
    /*
    Plugin Name: Page to Front
    Version: 1.0
    Plugin URI: http://wordpress.org/
    Description: Choose a page from the DB to display as the front page of your weblog.
    Author: Ryan Boren
    Author URI:
    */

    // Put the id of the page you want to display here. To find the page id,
    // go to Manage->Pages in the admin UI and look at the ID column.
    $ptf_front_page = 1;

    function ptf_front_page($query_string) {
    global $ptf_front_page;

    $query = new WP_Query();
    $query->parse_query($query_string);

    if ($query->is_home) {
    $query_string = add_query_arg(‘page_id’, $ptf_front_page, $query_string);
    }

    return $query_string;
    }

    add_filter(‘query_string’, ‘ptf_front_page’);
    ?>
    ‘`

    You can name it something like pagetofront.php or whatever you want really.

    2 . Next, create the page that you want people to see when they first come visit your site. You could make it as simple as just having text with your theme look, or you could create a whole new template for your home page and then just create it as a page.

    If you’re making a new template, don’t forget to add the following to the top of your php file:

    <?php
    /*
    Template Name: Home
    */
    ?>

    3. Note the number that the page is given when you create the page, and edit the plugin with the page that you want as your new “home page.”

    4. Next up, you’ll need to edit your permalink structure so that you’ll be able to get from your home page to the rest of your blog. Without setting up the permalink structure, I believe that you’ll have no way of getting back to your blog since the plugin will keep redirecting you back to the home page.

    You’ll want your permalink structure to look something like this:

    WordPress Address: http://mydomain.com/blog
    Blog Address: http://mydomain.com/
    Permalink Structure: /blog/%year%/%monthnum%/%day%/%postname%/

    That should be all that you need to do. You’ll now be able to have a static home page which is part of wordpress.

    All of this is assuming that you have wordpress installed in your root directory instead of a folder. You could do this if you had wp installed in a folder, but then your home page would be located at mydomain.com/wp with your blog then at mydomain.com/wp/blog.

    Hope this helps!

Viewing 15 replies - 16 through 30 (of 43 total)
  • yogaboat – I would be happy to help. But the forum is the forum. Post your question here and we will try to get you all fixed up.

    This is my front page

    http://www.beartribenet.com

    this is my log page

    http://www.beartribenet.com/log

    I didn’t do this my child did. Don’t you just hate it when your child cando something you can’t. : )

    Greetings!

    1. Are most people here now reliably using Ryan’s plugin?

    2. When I create the plugin, I assume I drop it into my plugin directory?

    3. Can people post more examples of their sites having followed this method?

    Thanks

    Root dear, what did you do with Aprodite? I’m getting a 404 (a real one, okay? *laughing*) I wanted to download it….

    Ryans plugin works great but the only problem I have is that the date of the post/page is displayed and I would rather just have the content without a date. Can I do this?

    @Madiebearti. Once you get into home.php being your front page it will reside in the same directory as the rest of your blog stuff. All this stuff in this thread is redundant and unnecessary.

    breger, take out the date call in your content section.

    What is it with you guys and plugins?. This functionality is built into WP.

    er, nope. wp only allows you to create a home.php file. and the wp query will seek to stick the latest posts on it.

    Ryan’s plugin will occur before the wp query. basically, it adds the home page id argument to the query. the downside is that your page will answer to is_page() rather than is_home(), and you’ll need to configure the page to use a separate template manually.

    my plugin bypasses the wp query clause _after_ the query detects that you’re on the front page. thus, you can safely use is_home(), and home.php will automatically be for your template if the file is present.

    I used this method on infinipedia.net

    • I created the “Page to Front” plugin and made it refer to a page with a custom template
    • I created another page for the blog main page named “eat” (with a custom template too)
    • Changed my blog’s homepage in Options to http://www.infinipedia.net/eat

    Now http://www.infinipedia.net opens the custom homepage, but all internal links to the homepage take me to the blog’s main page. Twisted but works.

    Er no not quite. Once you have home.php you can edit / delete the loop. The benefit of using a separate template is that the file can be edited locally and you can use ftp. It is not a meta file like a page. Plus if you want to use php in the template it is already set up.

    trevorturk said:
    there’s something about this in the codex. feel free to update it:
    http://codex.wordpress.org/Pages#Using_a_Page_as_the_Front_Page

    Obviously someone did “feel free to update it” since most of this information is missing . . .

    truenorth

    @truenorth

    Root –

    I understand the logic behind using home.php, however this seems to effect index.php. Now neither show any posts.

    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.

Viewing 15 replies - 16 through 30 (of 43 total)
  • The topic ‘Lesson: How to make a static page your “home” page’ is closed to new replies.
Skip to toolbar