• Resolved skysquare

    (@skysquare)


    I’m using wp-pagenavi on my site. On the archive pages it’s working fine, but on one of my subsites where I use a custom query for a category it somehow isn’t. All pages show the same content as page 1.

    The solution to this: Put

    <?php
    if (is_page(‘news’)) {
    $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    query_posts(“cat=10&paged=$paged”);
    }
    ?>

    before your loop:

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>

    You can replace the argument of is_page with whatever page you want, or an array of pages. Line 3 does the querying for the category.

    I guess it has something to do with an unrewound/mixed-up query or so, but creating a second query OR rewinding the loop afterwards didn’t make any difference.

    I can’t tell you exactly what it does, but it works. I stumpled upon this bit of code awhile ago and surprisingly needed it once more, so I thought I post this here instead of putting it underneath any of the numerous threads regarding this problem.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Solution to wp-pagenavi not working, content the same on all pages’ is closed to new replies.