[resolved] Solution to wp-pagenavi not working, content the same on all pages (3 posts)

  1. skysquare
    Posted 5 years ago #

    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

    if (is_page('news')) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

    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.

  2. scribu
    Plugin Author

    Posted 5 years ago #

  3. skysquare
    Posted 5 years ago #

    Okay, shame on me ;)
    I usually google a lot before posting. The truth is, I didn't even come across the FAQ-page since there was a tag-related forum here at WordPress.
    I've been doing a lot of coding today, so my head was a bit on overload.
    Sincerest apologies ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic