treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Limit number of post on archive page

  • 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(); ?>

    <div class="archives">
    <h4 class"archives-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
    <?php the_excerpt(); ?>
    <?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>


    </div>

    <?php endwhile; endif; ?>



    <div id="nextLink"><?php next_posts_link('Older News -->'); ?></div>

    <?php wp_reset_query(); ?>

    <?php get_footer(); ?>

  • Try this:
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts($paged . "&posts_per_page=1&paged=' .$paged);
    ?>
  • Thanks, but now I'm getting an T_endwhile error.
  • 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