Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My site is using the Faceted Search Widget upon reaching an archive page. The widget works fine provided you stay on the initial archive page, but if I try using it on the second page of the archive it works only if there are 8 or more entries to return, third page only if there are 16+.

It almost seems as though when wp is figuring out what page it's on it's one ahead of itself. Here is a pastebin of my archive page. Any thoughts as to why this is happening/how to fix it?

Pastebin with the faceted-search-widget

share|improve this question
add comment

1 Answer 1

Using query_posts is not advised anymore and in your instance, using it outside of a page template will cause strange results, query_posts is used for altering the main loop of your site, therefore its advised to use something like WP_Query instead.

Replace from line 14 of your code:

<?php
        //bad: do not use query_posts
        global $query_string;
        query_posts("{$query_string}&posts_per_page=8");
        if ( have_posts() ) while ( have_posts() ) : the_post();
?>

With this,

<?php
        //good: use WP_query instead
        $paged = get_query_var('paged');
        $wp_query = new WP_Query(array('posts_per_page' => 8, 'paged' => $paged));
        while ($wp_query->have_posts()) : $wp_query->the_post();
?>
share|improve this answer
    
Hmmm, unfortunately that doesn't appear to have made any difference. I've updated the pastebin to reflect your suggestion as well as added another pastebin for the plugin itself. pastebin.com/JctTtUSn I noticed "paged" doesn't appear anywhere within the plugin, could that be part of the issue? –  Chuck Jun 22 '12 at 18:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.