Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search results not displaying for multiple word search in WordPress

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.

Code for searchform.php below.

<form id="searchform" name="searchform" method="get" action="<?php echo home_url(); ?>">
    <div>
        <input type="text" id="s" name="s" />
        <input type="submit" id="searchsubmit" value="<?php esc_attr_e( 'Search', 'richwp' ); ?>" />
    </div>
</form>

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

like image 468
Mike Eng Avatar asked Oct 10 '22 10:10

Mike Eng


1 Answers

I would guess you need to decode the search term you are extracting from the query string, like so: $search_query[$query_split[0]] = urldecode($query_split[1]). Although, you could probably just use Wordpress's get_query_var function instead of all that code.

like image 72
Richard M Avatar answered Oct 13 '22 00:10

Richard M