0

So I'm having a weird issue that I've never seen.

I have a search.php set up like this:

 
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
query_posts($query_string . '&paged=' . $paged); 

if ( have_posts() ) : while ( have_posts() ) : the_post();
    // post stuff
endwhile; else:

endif;

pagination();


If I use anything but the default permalink structure, it breaks the pagination and returns a 404 and the second page.

Ant ideas?

5
  • Can you post a bit more context, please? What's in $query_string and where do you get it from?
    – wyrfel
    Commented Mar 4, 2011 at 5:40
  • There is no other context. That is all of the necessary info for the search.php template. $query_string prevents query_posts from ignoring the search query.
    – Pippin
    Commented Mar 4, 2011 at 6:47
  • Okay, just noticed something really strange. First of all, I'm pretty sure this is only an issue with 3.1 Second, if I hold my mouse over a pagination link (such as page 1, page 2, etc) the url is my-site.com/blogname/blogname/page/#. Notice how blogname is repeated twice? Now what is even weirder is that it only does this if the /page/ parameter is not already in the url, such as when I'm on the very first page. If I manually change the url to my-site.com/blogname/page/2, everything works fine.
    – Pippin
    Commented Mar 4, 2011 at 7:49
  • Oh, and it all works perfectly fine when on archive or blog pages.
    – Pippin
    Commented Mar 4, 2011 at 7:52
  • Alright, I've solved the problem. Turns out that you should never use action="<?php bloginfo('url');?>" for searchform.php. It will work perfectly fine in terms of search results, but it will break the pagination, when using 3.1. Instead, you should use <?php echo home_url();?> for the form action.
    – Pippin
    Commented Mar 4, 2011 at 14:43

1 Answer 1

0

Alright, I've solved the problem. Turns out that you should never use action="" for searchform.php. It will work perfectly fine in terms of search results, but it will break the pagination, when using 3.1. Instead, you should use for the form action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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