Forums

[resolved] Query posts and pagenavi (4 posts)

  1. stevenoi
    Member
    Posted 6 months ago #

    Hi, I made a blog template for my blog page and it must show every category except the "uncategorized" category. I've made a code that worked, but now when I install pagenavi I can't go to another page ( the same I had for the next and previous post link ). This is my code : `
    <?php
    /*
    Template name: blog
    */
    ?>

    <?php get_header(); ?>

    <div id="content">
    <div class="head"><h1>Blog</h1></div>
    <div id="block-3">

    <div id="content2">

    <?php query_posts("cat=-1"); ?>
    <?php while (have_posts()) : the_post(); ?>

    <div class="post">

    <div id="post_top">
    <div class="title"> "><?php the_title(); ?></div>
    <div class="comments"><?php comments_popup_link('0 Comments', '1 Comment', '% Comments'); ?></div>
    </div>

    <div class="pcontent">

    <?php the_content(); ?>
    </div>

    <div class="info_right">
    Author : <?php the_author_posts_link(); ?>
    Category : <?php the_category(' '); ?>
    Date : <?php the_time('d-m-y'); ?>
    Tags : <?php the_tags(' '); ?>
    </div>

    </div>
    <?php endwhile; ?>

    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>

    </div>
    <div id="sidebar">
    <?php get_search_form(); ?>
    <div class="sidebaritem">
    <h2>Categories</h2>

      <?php
      wp_list_categories('orderby=id&show_count=1&exclude=1&title_li='); ?>

    </div>
    <?php get_sidebar(); ?>

    </div>

    </div>
    </div>
    <?php get_footer(); ?>

    <?php endwhile; ?>
    </div>
    <!-- End Row 3 --!>
    </div>

    </div>

    <!-- End Block 2 --!>

    <?php endif; ?>
    <?php get_footer(); ?>
    `

    And it will show up like this : http://hee.awardspace.biz/blog/ . As you see it shows the same posts if you go to another page. I already figured out that the query_posts where the problem, but I don't know another way...

    - Steven

  2. stevenoi
    Member
    Posted 6 months ago #

    Bump ... ?

  3. stvwlf
    Member
    Posted 6 months ago #

    hi

    to have paging work correctly when using query_posts, you must use code like this

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
          query_posts("cat=-1&amp;paged=$paged"); ?>

    Try that - it should resolve the problem. Haven't tried this with the PageNavi plugin yet.

  4. stevenoi
    Member
    Posted 6 months ago #

    Thank you very much, it worked! Thank you again!!!!

Reply

You must log in to post.

About this Topic