Search results not displaying for multiple word se

2019-06-28 01:56发布

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.

2条回答
太酷不给撩
2楼-- · 2019-06-28 02:42

Line 16 of your search PHP

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

Try changing to this

$query_args = explode(" ", $query_string)
查看更多
smile是对你的礼貌
3楼-- · 2019-06-28 02:48

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.

查看更多
登录 后发表回答