With the release of version 3.7, WordPress search has taken on quite a few improvements. Gone are the days of sorting results in chronological order, exact keyword matches & so on. WordPress search has finally put relevance ahead of publish date, and included several new filters for developers to further expand the search experience with plugins. Let’s take a look at what’s changed.
Search Results Ordered By Relevance
WordPress search results are now ordered by relevance (date is still used as a secondary sorting parameter, but relevance takes precedence). According to this changeset on WordPress Trac, here’s how the new ordering logic works:
- Full sentence matches in post titles
- All search terms in post titles
- Any search terms in post titles
- Full sentence matches in post content
Consider each of these bullet points as a section. The search results in each section will be ordered by date (independently of the other sections). So… relevance first, date second.
WordPress Search Filters & Functions
A couple new filters have been added to WordPress core, allowing developers to further expand WordPress search. These filters have not been documented yet, but we’ll explain them below as best we can. For a full understanding of each filter, search for them on the WordPress Trac.
__return_empty_string()
– a function to return an empty string, for filterswp_search_stopwords
– filters stop words ignored in WHEREposts_search_orderby
– filters the ORDER BY when ordering search results
How will the new WordPress search change the way you develop sites? Are you more likely to use it now that it sorts by relevance first? Working on new plugins (or plugin updates) based on these filters?
We Recommend
https://kinsta.com › wordpress-hosting
Fast and secure infrastructure, worldwide CDN, edge caching, 35 data centers, and enterprise-level features included in all plans. Free site migrations.
https://gravityforms.com › features
Create custom web forms to capture leads, collect payments, automate your workflows, and build your business online. All without ever leaving WordPress.
Leave a Comment