Forums

[resolved] Category Pages: How to show more posts (6 posts)

  1. mimfrona
    Member
    Posted 10 months ago #

    I have the maximum number of posts set to one, because I only want one post to appear on each page.

    However, I also want to show many excerpts (say 10-15) when someone clicks on the category link.

    How can I modify things so a different number of posts is shown on these two pages?

  2. MichaelH
    moderator
    Posted 10 months ago #

    This example uses the WordPress Default theme. Just copy wp-content/default/theme/index.php to wp-content/default/theme/category.php

    Then edit that template file and change:

    <?php if (have_posts()) : ?>

    to

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts($query_string . '&showposts=10&paged=' . $paged);
    ?>
    <?php if (have_posts()) : ?>
  3. MichaelH
    moderator
    Posted 10 months ago #

    Oh and change the_content() to the_excerpt() in your category.php template.

    Related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

  4. mimfrona
    Member
    Posted 10 months ago #

    Thanks. This helped.
    I'm using a different template (Revolution Lifestyle), and there was no category.php file, just an archive.php file which controls the category pages.

    When I tried copying the index.php to the archive.php, I got an error message, but then I went back and added the code you gave:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts($query_string . '&showposts=10&paged=' . $paged);
    ?>

    to appear before

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

    which is what this template shows instead of

    <?php if (have_posts()) : ?>

    and this corrected the problem.

  5. MichaelH
    moderator
    Posted 10 months ago #

    The WordPress Default Theme does not have a category.php but it is easily created by coping another template to that file name. Of course the Template Hierarchy controls what WordPress uses to 'process' your theme.

  6. eanderson651
    Member
    Posted 4 weeks ago #

    Is there a way to limit this to only one category page or is it all or nothing?

    Thanks in advance!

Reply

You must log in to post.

About this Topic