Designer? Programmer? Enthusiast? Join Open Designs Now!

Open Designs Forum » Designer Talk

WordPress Theme Pagination Question

(3 posts)
  • Started 1 year ago by pseudoxiah
  • Latest reply from pseudoxiah
  1. pseudoxiah
    Member

    Hi guys.

    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?

    Posted 1 year ago #
  2. James
    Member

    The problem is that (at a guess??) you've set 10 posts to display per page in WP admin but the loop for the first page is only telling WP to show 3 posts.

    To fix it, you either need to change the number of posts per page to 3 (in WP options) or create a 'featured' section which involves 2 loops.

    This code may help you in the right direction:

    query_posts("paged=$page&showposts=7&offset=3")

    Posted 1 year ago #
  3. pseudoxiah
    Member

    Nevermind, I dropped the idea. It appears that any combination with query_posts or wp_query breaks the pagination somehow.

    However, the theme is kinda ready and I could use some beta testing. It is of course available under GPL :)
    http://bit.ly/o4Ndi

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.