WordPress.org

Ready to get started?Download WordPress

Forums

Need 'Home' page with 1 post and 'Blog' page that acts like the old home page. (10 posts)

  1. tbolt74
    Member
    Posted 5 years ago #

    My client has asked that only the most recent post be shown on the homepage and there should be a nav item called blog that would show the top 5 or 10 recent posts like the regular homepages do.

    How do I achieve this?

    Thanks,

    T

    PS - Running the latest version (2.8.4)

  2. equaldesign
    Member
    Posted 5 years ago #

  3. tbolt74
    Member
    Posted 5 years ago #

    Thanks, I'll check it out.

  4. tbolt74
    Member
    Posted 5 years ago #

    Ok. So I've created the static front page and my blog page as the tutorial states and everything is fine except how do I get the most recent post to show on my newly created 'static' front page called home?

  5. esmi
    Forum Moderator
    Posted 5 years ago #

  6. tbolt74
    Member
    Posted 5 years ago #

    Ok, am I just brain dead today or what. When you create a static front page, this page is created in the admin and therefore a stored page in the database. There is no actual file for this page and so my question to you is where do I place this code?

  7. esmi
    Forum Moderator
    Posted 5 years ago #

    Create a custom page template for your Home page and add the get_posts loop to that page.

    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

    You could add the get_posts block to your default page.php template file and surround it with a conditional so it only runs on the front page. But the custom template approach is a bit safer in that you can always revert to the default page template if your code goes pear-shaped. Which happens to everyone at least some of time. :-)

  8. dragonsjaw
    Member
    Posted 5 years ago #

    This is the code i use to pull the most recent Post onto my static front page and this is on a page template i created called : Main-

    '
    <?php $temp_query = $wp_query; ?>
    <?php query_posts('&showposts=1'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <h3>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></h3>
    <?php the_excerpt(); ?>

    '

  9. tbolt74
    Member
    Posted 5 years ago #

    Ok, I have it working now. However, since I've created the static front page http://www.domain.com/ does not resolve to is as it's now at http://www.domain.com/home and the rewrite rules that WP presented do not cover this.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

  10. esmi
    Forum Moderator
    Posted 5 years ago #

    Do you have a home.php file in your current theme? If so, try renaming it and set up a static front page following the normal route.

    http://quirm.net/2009/06/12/setting-up-a-static-wordpress-home-page/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.