Grow your CSS skills. Land your dream job.

Limit number of post on archive page

  • # November 8, 2011 at 2:43 pm

    keep getting an end syntax error. I am trying to limit the number of post displayed on a archive page. Thanks in advance.

    < ?php

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("posts_per_page=1&paged=".$paged);

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


    ">">< ?php the_title(); ?>


    < ?php the_excerpt(); ?>
    < ?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>




    < ?php endwhile; endif; ?>





    < ?php wp_reset_query(); ?>

    < ?php get_footer(); ?>

    # November 8, 2011 at 3:56 pm

    Try this:

    < ?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts($paged . "&posts_per_page=1&paged=' .$paged);
    ?>
    # November 8, 2011 at 4:10 pm

    Thanks, but now I’m getting an T_endwhile error.

    # November 9, 2011 at 9:15 am

    So I got the code to work with a lot of help, but now Im getting a 404 error when navigating to the next page. Here is my structure.

    -> parent category

    –> children category

    All of the children are displayed on a certain page. You select the category which then displays all the post within that category. This is where I want to limit the number displayed. Hopefully that gives a better picture.

    url for page that displays childern

    localhost/?page_id=5

    url for category selected

    localhost/?cat=4

    url for next post link which I get the 404 error

    localhost/?cat=4&paged=2

    Here is the complete code.

    Thanks in advance

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".