• Hi.

    I am developing a magazine style theme for WordPress. I want to display the latest 3 posts on the front page and on the upcoming pages the default number of posts.

    The problem is, it is displaying the first 3 posts on the front page and then on the next page it displays posts 11 to 20 or a 404 error if there are less then 11 posts published.

    Here’s the code I’m using:

    <?php if(!is_paged()) { ?>
      <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
        query_posts("paged=$page&posts_per_page=3"); ?>
      // The_Loop
    <?php } ?>
    <?php else { ?>
      <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
        query_posts("paged=$page"); ?>
      // The_Loop
    <?php } ?>

    So technically posts 4 to 10 are never displayed. Besides from that, the last page always displays a 404 error, although the link to it is displayed.

    Any ideas what i’m doing wrong?

Viewing 1 replies (of 1 total)
  • If you can stand 13 posts on the first page, and 10 on the rest, could just use a get_posts() loop for the first 3 posts and let the ‘normal’ loop display the remaining 10 posts and then let next_posts_link/previous_posts_link handle the rest.

    But, also wonder if Scott Reilly’s Inject Query Posts plugin might be useful…haven’t tried it but something to consider.

Viewing 1 replies (of 1 total)
  • The topic ‘query_posts and pagination problem’ is closed to new replies.