Search bar is just under the header and menu at the top of the page.

Example search: http://www.animefushigi.com/?s=bleach

Scroll down and try going to page 2, see it shows homepage instead.

Similar problem here, but the answer in that question did not work for me

I believe the issue is with my searchform.php.

I have pasted my searchform and search.php here: http://pastebin.com/raw.php?i=rSedK6AC

Any ideas on how to fix this ?


I think you are missing the $paged arguments

$paged = get_query_var('paged') ? get_query_var('paged') : 1;
| improve this answer | |
  • where does that go – GreatestSwordsman Mar 19 '12 at 2:39
  • I believe it should be right above the loop. – Vijay Sharma Mar 19 '12 at 16:25
  • another thing Chrome is giving a malware warning about your site. You may want to check it out. – Vijay Sharma Mar 19 '12 at 16:27
  • Yes that issue has been handled. And that should go above the loop in which file, the search.php ? – GreatestSwordsman Mar 20 '12 at 20:44
  • great... I am glad it worked for you.. – Vijay Sharma Mar 21 '12 at 21:37

Edit your index.php file.
Insert the $paged statement immediately prior to your post query. So something like this:

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$recent = new WP_Query("showposts=10&paged=" . $paged); while($recent->have_posts()) : $recent->the_post();?>
| improve this answer | |
  • Well my index.php does not need paging. But I tried your suggestion, and now the only difference is that it shows page 2 of the homepage instead of page 1. Index.php is not the problem I think. – GreatestSwordsman Mar 19 '12 at 2:37

This is how I solved it. I needed to recreate the query arguments based on the querystring. I wasn't able to find another way to do it.

Insert the following before the loop.

global $query_string;

$query_args = explode( "&", $query_string );
$search_query = array();

foreach( $query_args as $key => $string ) {
    $query_split = explode("=", $string);
    $search_query[$query_split[0]] = urldecode($query_split[1]);
} // foreach

$search_query['posts_per_page'] = get_option( 'posts_per_page' );
$search_query['paged'] = $page;

$wp_query = new WP_Query( $search_query );

What I'm essentially doing is pulling down the entire querystring, parsing each key/value pair, and inserting into a new wp_query argument list. I'm also setting the paging parameters of the argument list separately.

| improve this answer | |

It's 2020 and I still had the same issue. Didn't find a solution anywhere; posting it here in case it helps someone else.

I solved the problem by editing .htaccess. In my particular case, this was messing things up:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
| improve this answer | |

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.