« back to home

05 - WordPress Search Functionality

Description

The WordPress search allows users to to search the website for terms that occur in posts. It does not search through pages, only the content of posts. The results are ordered based on relevance, first including full-sentence matches in the title, then all search terms in post titles, followed by any search terms in post titles, and finally full-sentence matches in the content.

Role of the URL

By default, "?s=search-query" is added at the end of the URL when a WordPress site is searched. This means that search results can be bookmarked or shared via the URL.

How to Show the Current/Active Search Term

By using WordPress' get_search_form() function, the search box will automatically be added. When a user enters a query and hits search, their active query will remain in the search form field. The active query can also be accessed using the the_search_query() function in WordPress.

Summary

About 30% of WordPress site visitors use search to navigate a site to quickly find what they are looking for. Search is a very important part of a website, so it is important to understand the default WordPress search functions and limitations.