Better Search Pro enhances the WordPress REST API search resultsOpens in a new window to show posts ordered by relevance. When you enable this feature, a REST API search is performed, and Better Search Pro applies the default search configuration, just as it does for standard WordPress search requests.

WordPress core utilizes the REST API in various scenarios, including the ‘Add Link’ modal when searching for content. If you’ve customized Better Search settings to use specific configurations for admin searches, those settings will be applied in these cases as well. Depending on your search setup, this may result in unexpected behavior.

Enable REST API support

You can enable this by navigating to Better Search > Settings and turning on REST API search integration on the Features tab, then saving the settings. Before v4.5.0 this was the Enable REST API setting on the General tab. Alternatively, you can pass better_search_query as the parameter to enable relevance searching.

REST API parameters

ParameterDescription
better_search_queryEnables Better Search for the REST API query when set to true.
search_excerptIncludes post excerpts in the search query.
search_taxonomiesSearches within taxonomy terms (e.g., categories or tags).
search_metaSearches within custom post meta fields.
search_authorsEnables searching by author names.
search_commentsIncludes post comments in the search query.
search_slugEnables searching within the post slug.
exclude_protected_postsExcludes password-protected posts from the search results.
exclude_post_idsA list of post IDs to exclude from the search results.
exclude_categoriesA list of category IDs to exclude posts from those categories in the results.
weight_titleSets the weight for matching keywords in post titles.
weight_contentSets the weight for matching keywords in post content.
min_relevanceFilters results to only include those with a relevance score equal to or greater than this value.

All parameters are optional. If not provided, Better Search will use its default configuration. You can use these parameters to fine-tune search behavior for specific REST API requests.

See also

  • Better Search Abilities API — a separate endpoint under wp-abilities/v1 that exposes Better Search to AI assistants. It does not change the WordPress search endpoint described on this page.

Was this article helpful?

0% found this helpful (1 votes)