• Resolved mimfrona

    (@mimfrona)


    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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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()) : ?>

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

    Related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

    Thread Starter mimfrona

    (@mimfrona)

    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.

    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.

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

    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Category Pages: How to show more posts’ is closed to new replies.