You don’t really need to use the &new WP_Query
just new WP_Query
.
The following code will resolve your problem.
add_filter( 'posts_search', 'q166788_search_modify', 10, 2 );
function q166788_search_modify( $sql, $query ){
// Only if our variable is true we do the black magic
if ( ! isset( $query->query_vars['search_conditional_toggle'] ) || $query->query_vars['search_conditional_toggle'] !== true ){
return $sql;
}
return preg_replace('/AND/', 'OR', $sql, 1 );
}
// The actual search
$s="bord";
$args = array (
'author' => '1,2,3,4,5',
's' => $s,
'search_conditional_toggle' => true, // Make the black magic happen
'posts_per_page' => -1
);
$allsearch = new WP_Query( $args );
var_dump( $allsearch );
Related Posts:
- Post_count only shows the number of results per page
- WP Query where title begins with a specific letter
- Search custom taxonomy term by name
- Order Search Results Page by meta_value If no Value Return Remaining Results
- Tracing the life of a query
- Pagination not working for Custom search form & custom result template
- Pagination broken when merging search results with additional WP_Query
- How to search by title or tags exclusively?
- WordPress search exact match
- How do I search WordPress by different fields without a plugin?
- Multiple keyword search
- Using next/previous_posts_link with customised search
- WordPress custom search form with pre_get_posts not work
- Add custom search results to main WP search [duplicate]
- WP Query search for attachments and their exact title
- How do I search inside specific taxonomies in WordPress
- Modifying the Search Results
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Creating a custom search for a specific post type
- Custom Search Result Page displaying only 1 result.
- How to loop for every result found in the_content() when using the search query?
- showing all search result in one template
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- Is there any advantage of using default WordPress Search instead of creating a custom one?
- WP_Query Not Recognizing Taxonomy Parameter in Custom Search
- Search pages that are a child of the current page
- Include tags in WP_Query
- Search for multiple tags?
- Custom Search Not Consistent with Results
- Editing the default wordpress search
- How to use wp_query to post count by search term > group post count by date > convert to json. (ex. result 12-21-2020 – 343)
- Multiple Search Terms WP_Query
- Extend product search with meta in WooCommerce
- WP Query Args – Title or Taxonomy Value
- wordpress search word, “hello world” ===> ‘hello+world’ ===> ‘hello’, ‘world’
- Query with search and subscribers only output
- Search by post id in a specific page then auto-redirect to searched post
- Search for “2nd” also returns “22nd” in wp_query
- Categorising search results based on Custom Fields
- Add filter post_where and passing post_type argument
- using pre_get_posts for search results not found
- Modify Search Query if original Query gave no results
- Include post content of linked posts in search
- How do I amend wp_query before it is run/executed?
- wp_query search not taking keywords with together for multiple words
- Wildcard search in WP Query
- Search Page Returns Nothing
- Redirect Search to Form When No Product Results Are Found
- How to properly use AND / OR in custom search
- How to avoid bypass of search bar rules?
- Hide products in uncategorized category from search results
- How do you determine if a result in a search query is a post or a page?
- wp_query show all values
- change posts_orderby of the callback wp_query?
- How to restrict search on a certain page to only return results against custom taxonomies?
- Ignore image urls in wp_query search
- Search.php – return number of results but cannot loop through
- How to filter a static post page with ajax and $wp_query
- Searching not only by post name but also category
- $wp_query->found_posts not returning correct value
- How to search by slug and old slug in single API
- WordPress search WP_Query to cover multiple post types and their custom fields?
- How to prevent WP_Query from filtering on ‘s’ but keep ‘s’ for other purposes?
- Block internal search queries with pre_get_posts and regex rules
- Add dynamic search to paginated WP_Query
- Search Exact on WordPress – Relevannsi Solution Not Working
- Pagination repeating posts on search results
- I have problems with the search query using multiple post types
- Multiple WP_Query args combinations according to post type
- Categories In English version showing not canonical URL, instead shows query search result
- Filter admin ajax data by url query
- Display the search results like the original pages
- How to use jQuery validation to set the search bar to accept only a specific input?
- How to debug none working search query?
- Search with WP_Query, but ignore href URLs in anchor tags?
- WordPress search page pagination displaying but not functional
- Limit default Search query to post_title
- Search Field that allows options of “Match any keyword” or “Match all keywords”
- Order & Orderby clause not working with custom query
- How can I modify standard search query to include also ACF custom fields values?
- How to make the default WordPress search return borader results
- WordPress WP_Query offset parameter not working with search parameter
- WordPress WP_Query Array Custom search via taxonomies
- Need help setting up a search form for wordpress [duplicate]
- Search Query that Includes Custom Table
- Manipulating a query
- Custom search: Search posts but display parent page in results
- Query posts by custom fields
- Searching in specific custom post type
- Search (Custom Form, Custom Search Result)
- Help with showing text when something is entered in my search bar
- Filtering product search results using tags
- Using ‘meta_query’ with the ‘pre_get_posts()’ hook disables searching for post titles
- WordPress WP_Query Search (‘s’) With Multiple Search Terms
- Search query alteration not working for meta values
- Search results stuck on page 1
- Advanced Search – Is this possible?
- How to include custom fields in wordpress search
- Extend search query to search meta keys values based on search string
- AJAX multiple search boxes not merging with array merge