query - Modify behaviour of "s" parameter in wp_query

admin2025-01-07  3

I'm having an issue with the "s" parameter in wp_query.

When someone search a text with two or more words, wp_query split the criteria in two or more parameters. For example :

[no_found_rows] => 
            [search_terms_count] => 3
            [search_terms] => Array
                (
                    [0] => online
                    [1] => books
                )

        [search_orderby_title] => Array
            (
                [0] => wp_posts.post_title LIKE '%online%'
                [1] => wp_posts.post_title LIKE '%books%'
            )

How can I modify that behaviour in wp_query, so if I search "Online books" just use the whole text?

Thanks in advance.

I'm having an issue with the "s" parameter in wp_query.

When someone search a text with two or more words, wp_query split the criteria in two or more parameters. For example :

[no_found_rows] => 
            [search_terms_count] => 3
            [search_terms] => Array
                (
                    [0] => online
                    [1] => books
                )

        [search_orderby_title] => Array
            (
                [0] => wp_posts.post_title LIKE '%online%'
                [1] => wp_posts.post_title LIKE '%books%'
            )

How can I modify that behaviour in wp_query, so if I search "Online books" just use the whole text?

Thanks in advance.

Share Improve this question asked Jun 12, 2018 at 16:37 Rodrigo MoyaRodrigo Moya 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

This works the same way Google etc work, to search for an exact phrase, wrap it in quotes

e.g. online books vs "online books"

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736255458a283.html

最新回复(0)