0

I've searched thousands of related posts and can't seem to get the pagination to work on this loop.

As soon as i click next page i get a 404

//get the search term
if (!empty($_GET["s"])){
$s = $_GET["s"];

//the search form will have an input value of "Search..." if nothing has been selected. We need to clear 
if ($s=="Search..."){
    $s='';
}
}

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$limit = 10;
     $args = array(
    //the user inputed search term
    's' => $s,
    'post_type' => 'schools',   
    'posts_per_page' => 5,
    'paged' => $paged,
    //we use tax_query here to query the schools custom taxonomy. 
    'tax_query' => array(
        'relation' => 'AND',
        array(
            //name of school categories (custom taxonomy)
            'taxonomy' => 'school_category',
            //we are going to search by matching category ids
            'field' => 'id',
            //the array we created that contains all the category ids to be searched
            'terms' => $category_and,
            //we want to make sure only posts in all of the categories selected are shown.
            'operator' => 'AND'
        ),
        array(
            //name of school categories (custom taxonomy)
            'taxonomy' => 'school_moi',
            //we are going to search by matching category ids
            'field' => 'id',
            //the array we created that contains all the category ids to be searched
            'terms' => $category_MOI,
            //we want to make sure only posts in all of the categories selected are shown.
            'operator' => 'AND'
        ),
        array(
            //name of school categories (custom taxonomy)
            'taxonomy' => 'school_curriculum',
            //we are going to search by matching category ids
            'field' => 'id',
            //the array we created that contains all the category ids to be searched
            'terms' => $category_cur,
            //we want to make sure only posts in all of the categories selected are shown.
            'operator' => 'AND'
        )

    )

);

//The new query with our arguements
$wp_query = new WP_Query( $args );

woo_loop_before();

if ($wp_query->have_posts()) { $count = 0;

$title_before = '<h1 class="archive_header">';
$title_after = '</h1>';

//echo $title_before . sprintf( __( 'Search results for &quot;%s&quot;', 'woothemes' ), get_search_query() ) . $title_after;    
    ?>

<div class="fix"></div>

<?php
    //Make sure the search results take into account the categories chosen on the seach bar

    while ($wp_query->have_posts()) {$wp_query->the_post(); $count++;

        if (get_option('woo_woo_tumblog_switch') == 'true') { $is_tumblog = woo_tumblog_test(); } else { $is_tumblog = false; }

        woo_get_template_part( 'content', 'search' );

    } // End WHILE Loop



    next_posts_link('&laquo; Next');
    previous_posts_link('Previous &raquo;');

    //wp_reset_postdata();

  } else {
get_template_part( 'content', 'noposts' );
  } // End IF Statement


  woo_loop_after();

I have the blog pages show at most option set to 1.

Help would be really appreciated!

Thanks

0

i think that you need to use wp_reset_query(); before woo_loop_after();

  • nope, i had reset query at the bottom of the page. Tried moving it as per your suggestion, but no luck. – user1917727 Nov 7 '13 at 10:46
  • please update your question with last code you tried – adnan Nov 7 '13 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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