Forums

Only most recent post on home page (6 posts)

  1. tactics
    Member
    Posted 3 years ago #

    OK, this is strange because I've seen a lot of people posting the same question, but no clear answer. What I'm trying to do *should* be very simple - show only the most recent post (in it's entirety) on my home page. Here's what I've got going now that doesn't work:

    <?php
    query_posts(array('showposts' => 1));
    get_header(); ?>
    <?php get_sidebar(); ?>
    <div id="content">
    <?php if(have_posts()) : ?>
    <?php while(have_posts()) : the_post(); ?>
    <div class="post">
    <h1 class="pageTitle"><?php the_title(); ?></h1>
    <h2 class="date"><?php the_time('F jS, Y') ?></h2>
    <?php the_content(); ?>
    </div>
    <?php endwhile; ?>
    <?php if (show_posts_nav()) : ?>
    <div class="pagination">
    <span class="prevlink"><?php next_posts_link('Older Posts'); ?></span>
    <span class="nextlink"><?php previous_posts_link('Newer Posts'); ?></span>
    </div>
    <?php endif; ?>
    <?php else : ?>
    <div class="post">
    <h1 class="pageTitle"><?php _e('Not Found'); ?></h1>
    </div>
    <?php endif; ?>
    </div>
    <?php get_footer(); ?>

    I'm still getting 10 posts on my home page.

    Any ideas?

  2. Samuel B
    moderator
    Posted 3 years ago #

    admin - settings - reading
    set it to 1

  3. tactics
    Member
    Posted 3 years ago #

    Then it sets all the pages to only one. I want my categories pages to have ten. I just want my home page to have one.

  4. sandrine60
    Member
    Posted 3 years ago #

    Hi,
    You can use this plugin. http://www.maxblogpress.com/plugins/dppp/use/ I'm on wp 2.7 and it works perfectly. Don't be stopped by the installation process- you'll need to registered. After it does excatly what you was asking for.

  5. tactics
    Member
    Posted 3 years ago #

    I'll check it out, thanks.

    In the meantime, I managed to get it to work by creating a "home.php" page and using this:

    <?php query_posts('showposts=1&amp;cat=0'); global $more; $more = 0; while (have_posts()) : the_post(); ?>

    That retrieves the latest post from category number 0

  6. mrwolfy
    Member
    Posted 2 years ago #

    how is the code working for you? I was searching for the exact same thing. Thanks for the info.

Topic Closed

This topic has been closed to new replies.

About this Topic