WordPress Search

Search Functionality

The bare bones search, without any extra code or a plugin added uses MySQL. In SQL the query argument name is “s”. The basic search is “is_search()” true. Then it ranks by post_content, post_title, and post_date in that order. There is priority set so the full sentence matches of post title come before all search terms in title match. Any search terms in post titles come next followed by matching a full sentence in the post content.

the role of the URI when searching

In the URL of a search, you will see your requested word, or phrase at the end of the URL. For an example I added a basic search function to my personal site BrunhildaAndHepCat.com. I then clicked on the search icon and typed “contact” then the enter key. I got back my contact page and https://brunhildaandhepcat.com/?s=contact was in the URL.

how to show the current/active search term in search form field

To display the current search in the search field you can add code to the value attribute in the form.

Summary

Adding a simple search function is really simple. There is some work to be done if you want it to more than just take you to the searched item.