I've customized a theme and am having some problems with search results using multiple-word queries. Site is live at www.abetterworldbydesign.com

Searching for a single word works as expected.

Searching for multiple words that should have returned results shows blank results.

Oddly enough, manually changing the "+" character in the URL to "&" displays the results correctly but only shows the first word in the header "Search results for:_".

My code in search.php for initializing WP_Query follows exactly the code listed in the codex. Full code for search.php on pastebin.

Code for searchform.php below.

<form id="searchform" name="searchform" method="get" action="<?php echo home_url(); ?>">
        <input type="text" id="s" name="s" />
        <input type="submit" id="searchsubmit" value="<?php esc_attr_e( 'Search', 'richwp' ); ?>" />
  • 1
    Pretty sure the correct way to search for multiple words is with a +, anything you add on with an & will get treated as a seperate query paramter. I'm not 100% sure though.. been a while since i've examined the search code.
    – t31os
    Jul 26, 2011 at 15:06

1 Answer 1


Answer from Richard M on the question originally asked on StackOverflow:

Replacing line 21 on search.php with $search_query[$query_split[0]] = urldecode($query_split[1]) resolved it.

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.