Fixed:
Search and result the all keys;
<?php
$the_keys = preg_split('/\s+/', str_replace('-',' ',get_query_var('s')),-1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
$total_keys = count($the_keys);
$the_query = new WP_Query(array('post_type'=>'nothing'));
if($total_keys>1){
for($i = 0; $i<=$total_keys; $i++) {
$the_query_mask = new WP_Query(array('s' => $the_keys[$i]));
$the_query->post_count = count( $the_query->posts );
$the_query->posts = array_merge( $the_query->posts, $the_query_mask->posts );
}
} else {
$the_query= new WP_Query(array('s' => get_query_var('s')));
}
if ($the_query->have_posts()) : ?>
Note: 'post_type'=>'nothing'
just need array merge!
Related Posts:
- Modifying the Search Results
- wp_query ‘s’, search filter with pagination is not working
- Display filtered results into custom page
- My combination of ‘post_type’ and ‘tax_query’ not working?
- Can I force WP_Query to return no results?
- How to list some posts first in the loop based on post id
- WP_Query – filter or directly?
- What is the most efficient way of querying posts based on visits and date for current day?
- ajax category filter
- How to order posts tag by tag?
- Want to redirect if search query match exact title of any post
- Overriding The Loop with filter or hook
- Custom query incorrectly returning everything [closed]
- WP Rest API v2 return posts with specific tag
- Custom search form with empty parameters
- Search – Ajax – Alter Query Parameters with Pagination
- Multiple search queries on one page
- tax_query shows no results if nothing is selected
- Including only current user’s posts in search
- Refine/Filter WP_Query Posts with jQuery or Ajax
- How to apply filter inside a single wp_query?
- When to add_filter() to Custom Query
- Custom category search box for WordPress
- Refine search results using WP_Query
- Order by custom table and multiplication
- Search Posts with Custom Fields as query
- Assigning a meta_query value based on regexp to wp_query fails
- How to create a WordPress Post Filter that users can use to filter posts by year?
- add_filter() depending on search term
- query_vars filter not working even though query string parameter is present
- How do I run through a WordPress loop called from a filter function?
- How to filter, restrict and return posts based on custom user meta information
- Bypass “supress_filters” in WP Query
- How to use the query hook/filter?
- WordPress pagination not working on template search.php
- Cutom wp_query for geolocation search, pagination not working
- How to filter my search in post if contains a word in title, content or excerpt?
- Search Query for multiple categories using ‘OR’ but having certain categories be ‘AND’
- query_vars overriding WP_Query args
- how can I override The Events Calendar query modifications?
- How to make search for posts using get method?
- How to alter local query, not main query [duplicate]
- How to filter a query by date in a shortcode?
- How can I allow sticky posts but cap the query to 1 post?
- Search posts missing a particular custom field
- How do I get my custom query to work with search results after the first page?
- Replacing search results with custom external query
- Prevent author bio page from showing in search results
- Changing the default wp_search_stopwords
- How do I amend wp_query before it is run/executed?
- Get a list of posts by specific category
- WordPress Custom Search Form Displaying Unexpected Results
- Is it possible to add an argument to a custom function added to a filter hook?
- Slow Query On Search
- Sorting search results with custom dropdown
- How To Keep Search Title the same on paged Results
- Filter out a meta key in the Search results page with two CPT
- Query by key or author
- Can I make a search query which includes a space?
- Searching not only by post name but also category
- meta_query weird behaviour, static int will work, but not user data
- Block internal search queries with pre_get_posts and regex rules
- How to make the WP query search for the “s” arg in other places too
- Search Exact on WordPress – Relevannsi Solution Not Working
- Excluding posts from search results page with meta query not working
- I have problems with the search query using multiple post types
- WP_Query no result if keyword contains number
- How to extend WP_query to a specific table?
- Display Search Results by tag_ID in my search.php
- getting posts by tags
- Add to search posts query array with post IDS which will appear first
- Custom Post Type WP_Query with filters and search
- Get posts by similar names and categories
- Logging search queries for logged-in users
- get term objects and post objects in query
- How to show terms from another taxonomy
- Search Field that allows options of “Match any keyword” or “Match all keywords”
- How to set selected attribute on option after filter query?
- Issue generating custom filter for cpt admin columns
- A very strange problem with search query
- Custom query with post_class filter using current_post not working
- Search format not matching taxonomy query
- Search Functionality broken by the wp 4.2 update
- Custom search (wp query by custom fields)
- Filter WP_Query output before it is accessed (pre_get_posts)?
- Custom Search Query – include only custom fields and title
- $wp_query when new WP_Query
- Search Query that Includes Custom Table
- Loop the posts between two dates selected using jquery datepicker
- Why does WP_Query not search for two ‘meta_query’ keys separated with OR?
- Edit WordPress loop, taxonomies, & filter
- List categories using WP_Query
- 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
- WP_Query filter Posts by timestamp event (range start and end) and by month (next 12 month)