WordPress search term pagination broken

I’m having an issue with the pagination in search archives. For some reason whenever I try going to the next page the pagination gives me a 404.

It’s a default if (have_posts()) : while (have_posts()) : the_post(); loop.

Read More

I don’t know how, but I think the reason is because I’m getting redirected to a new page that get’s generated somehow. Say I search for stoff. Instead of /page/2/?s=stoff it replaces it with ?attachment_id=550&s=stoff.

Here’s what I’ve tried to do (with no different results)

  • Change the search query (attachment_id is the same here as well)

  • Change pagination functions (pagenavi, get_next_posts_link, custom function)

  • Replacing loop content with just a title

  • removing header, sidebars, footer

  • resetting post data

  • Resetting permalinks (pretty)

You can test the pagination live here (dev location)

Any thoughts on this are greatly appreciated 🙂

EDIT
Added Pagination code currently used in search.php

I don’t think it should be a problem with the pagination, seeing that I’ve tried so many different ones, and this pagination still works in every other location at the site, but here it is:

// Numeric Page Navi (built into the theme by default)
function bones_page_navi() {
  global $wp_query;
  $bignum = 999999999;
  if ( $wp_query->max_num_pages <= 1 )
    return;
  echo '<nav class="pagination">';
  echo paginate_links( array(
    'base'         => str_replace( $bignum, '%#%', html_entity_decode( get_pagenum_link($bignum) ) ),
    'format'       => '',
    'current'      => max( 1, get_query_var('paged') ),
    'total'        => $wp_query->max_num_pages,
    'prev_text'    => '&larr;',
    'next_text'    => '&rarr;',
    'type'         => 'list',
    'end_size'     => 3,
    'mid_size'     => 3
  ) );
  echo '</nav>';
} /* end page navi */

The function get’s called after the endwhile;

Related posts