i agree w/ chip, you need trim()
i’d try replacing:
$keys = implode('|', explode(' ', get_search_query()));
with
$keys = implode('|', explode(' ', trim(get_search_query())));
Related Posts:
- Matching a space in regex
- Genesis – Customize search form
- Modifying widget search box
- Rewriting search and pagination base
- How to find objects by terms
- How to create a WP_Query to search the Title or Tag?
- Adjust the results quantity for Search Results page pagination
- How to block specific keywords from searching on WordPress?
- How do I get images (with a thumbnail preview) to show in search results?
- sql query to put quotes around numbers in img tag
- Enhanced WordPress Search
- How do I dynamically generate args for wp_query?
- Wrap First Character after in a tag
- Add relevant tag to search results
- Use wp_get_recent_posts with search term
- If search results empty then execute certain code
- Count the number of times the search form template gets included on a page
- have_posts() execution failure
- esc_url returns incorrect URL
- Change Navigation Bar based on logged in or not
- Can’t search posts using WP_QUERY inside AJAX Function
- Only show search results with if current date is between two dates?
- WordPress pagination not working with search page
- Input type search in Menu
- How to make a search button that will search my website?
- WordPress Search Results for Multiple Post Types
- WP Query with custom Shortcode
- Customising the search function?
- How to add seperate classes to no-search-result and found-search-result pages on wordrpess search – is_search()
- Custom search results page not working with empty search
- Applying A Category to Existing Posts Where Page Title Matches Regex
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Save Search System
- Seach custom post type posts only by meta fields?
- Extend PHP regex to cover “srcset” and “style” attributes
- Autocomplete search box
- edit search.php to include subdomain posts
- Search Query: how to construct a search string from two select elements?
- Can anyone offer any help with this function?
- how to remove colon and white space in a string by php
- Get URL from shortcode tag
- get_users meta_query: REGEXP not working for matching new lines
- Search WordPress using static html page
- Exclude posts with specific metadata from search?
- Use Tags to initiate Search
- Preg_Match(): compilation failed unknown property name
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- preg_replace regex problem
- Form search query – displaying ACF “Post Object” field as results
- How to add no follow to specific links?
- Extract links from content
- How do I remove duplicate users from two merged WP_User_Query objects?
- WordPress Search
- WordPress pagination not working in search result page
- Search page results conflicting logic – Search result caching?
- Search.php gets metadata from first post
- search and add in wordpress content
- Testing a Form’s Zipcode Field with Regular Expressions to Determine WordPress Page Behaviour
- How can I modify this code to make the search box include tags and meta
- Free search and custom taxonomy query not providing the same result
- Display WordPress search results based on the selected Sub-Category
- WordPress Search Ajax + Isotope + InfiniteScroll
- how can i include post meta in search result
- My worpress search page is showing no results
- Replace a single variable with add_filter
- Integrate admin plugin into template. Very interesant (live search + autocomplete with wp rest api, in vanilla js)
- How to search order using database frontend short code WordPress
- Change ajax live search results
- meta_query search names when they have middle initials
- Limit Search to Product Pages only unless I’m on Blogpage or Blogposts
- Adding ELSE argument to AJAX Live Search for “No results found”
- How can i find wrong word in search box and replace with correct word
- Showing search results on a page
- What is the correct way to search 3 custom fields only in WordPress?
- Search only for posts with specific metadata?
- Search function not working
- WordPress add_rewrite_rule
- My search results are only showing 5 posts?
- making a search.php query
- How can I include tags in wordpress search without a plugin
- Search results template listing all posts
- Search bar for page that searches only particular page IDs
- RegExp to EXCLUDE strip HTML (FOR SOMME) comments
- Limit Search Queries per IP per Day
- Select All not working in a WordPress search filter
- Different layout on search page depending on category post
- Make the text field in search form optional
- Search box background on a different page template
- Search through documents folder
- Trying to put a search page on site
- Dynamically append custom post type to end of url
- Search result page – display values from the result’s metaboxes
- The search doesn’t work properly
- Search results always returns “No results” no matter what
- Is there a way to get wp_editor (tinymce) content?
- How to make WordPress search.php display all strings found on pages or posts
- How to cut a section of a URL from a string with a regular expression?
- Search custom post type posts only by meta fields?
- Limit a search box by CPT + taxonomies, in only one page
- Product Search in search.php