• Resolved jordashtalon

    (@jordashtalon)


    I’m looking at the archive.php page and I want to change the default amount that it shows.

    I’m looking here http://codex.wordpress.org/Category_Templates

    And it says to use

    <?php query_posts(‘cat=1&showposts=’.get_option(‘posts_per_page’)); ?>

    How would I get the category id stored in a variable?

    $catid=????

    Thanks

    Jordan

Viewing 7 replies - 1 through 7 (of 7 total)
  • It is UNTESTED, but I think this will work:

    <?php $cat = '';
    if (is_category()) $cat = 'cat=' . get_query_var('cat') . '&';
    query_posts($cat . 'posts_per_page=' . get_option('posts_per_page')); ?>
    Thread Starter jordashtalon

    (@jordashtalon)

    It kind of worked, it shows 20 posts per page, but the paging doesn’t work, when I try and view previous entries it gets a 404 error.

    I added this to the top of archive.php

    <?php $cat = ”;
    if (is_category()) $cat = ‘cat=’ . get_query_var(‘cat’) . ‘&’;
    query_posts($cat . ‘posts_per_page=20’); ?>

    Give this a try:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $cat = '';
    if (is_category()) $cat = 'cat=' . get_query_var('cat') . '&';
    query_posts($cat . "posts_per_page=20&paged=$paged")); ?>
    Thread Starter jordashtalon

    (@jordashtalon)

    That produces a syntax error, i’m not sure where.

    I think one too many close parens on the query_posts line:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $cat = '';
    if (is_category()) $cat = 'cat=' . get_query_var('cat') . '&';
    query_posts($cat . "posts_per_page=20&paged=$paged"); ?>
    Thread Starter jordashtalon

    (@jordashtalon)

    Yeah, that worked perfectly! Thank you so much for your help!

    Glad it worked. Now, please use the dropdown at top right to mark this topic ‘Resolved’.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Change the amount of Posts on the Archive.php page’ is closed to new replies.