Forums

[resolved] Limit front page only to one post (6 posts)

  1. neilcreek
    Member
    Posted 7 months ago #

    I would like to display a single post on the front page, but more ont all other pages, such as categories,search results and archives. When I select "show at most" x posts in the settings, this applies to all pages.

    Any suggestions?

    Thanks for the help!

  2. MichaelH
    Moderator
    Posted 7 months ago #

    Could use the showposts=1 parameter with the Template Tag, query_posts.

  3. neilcreek
    Member
    Posted 7 months ago #

    Beautiful! That did just the trick, thank you!

  4. tinuviel
    Member
    Posted 1 week ago #

    I'm at a loss as to how to implement this on my own site. I've entered:

    <?php
       if (is_home()) {
          query_posts("showposts=1");
       }
    ?>

    before these lines:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    And the result is that it restricts the first page of my site to the last entry - which is good. But when I click on the "Older Entries" link, all I get is the same single post again, over and over. Nothing else appears.

    If I place that If statement like so:

    <?php if (have_posts()) : ?>
    <?php
       if (is_home()) {
          query_posts("showposts=1");
       }
    ?>
    <?php while (have_posts()) : the_post(); ?>

    the result is the same.

    What am I doing wrong? I haven't set up a home.php file, as that also did not work. This is going straight into my Main Index Template.

    Thanks for your assistance.

  5. tinuviel
    Member
    Posted 1 week ago #

    Okay, I've changed my query to

    <?php
    if (is_home()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("&posts_per_page=1&paged=$paged");
    }
    ?>
    <?php if (have_posts()) : ?>

    But it's only showing one page on every page now, though the post IS changing. I only want it to show one post on the home page (I assmed that's what the "is_home" would take care of - but it's not???).

    Thanks again for any clarification.

  6. tinuviel
    Member
    Posted 1 week ago #

    No suggestions?

Reply

You must log in to post.

About this Topic