WordPress Search Functionality
WordPress includes the ability to search and look for content within a website. A user inputs into a search box that is connected to the search system, and it uses that information to search across page titles, page content, single-image titles or captions, image alt test, and file names using the WP_Query class. It will return results depending on the level of match with the query and shows the most recent pages or posts. It has some limitations as WordPress does not search widgets, comments, categories, or tags. How it orders its search results can also be difficult to sift through for websites with a large amount of posts or online stores, but there are options available to enhance the ability for users to search within a WordPress website including plugins or adding custom code.
The role of the URI when searching
The URI is the way WordPress sends the search query and its parameters to the server and plays a role in how the results are displayed to the user. The query is appended to the end of the URI, and the resulting page is the search results for that query and is usually displayed using the search.php template file. By default, what is added to the URI is /?s=search term but code within the functions.php file can be added to display the URI differently in more human-oriented language. Changing how the URI is displayed to being more human-like language also improves SEO, or Search Engine Optimization.
How to show the current/active search term in search form field
The URI is one place where users can see what search term or query has been processed. Another way is by including the information within the page itself using the search.php template file, including the following PHP code within a header element: get_search_form(); and _e ( 'You are searching for "' . get_search_query() . '"' ). If the search bar is located on the page being viewed, a user can also see what was typed in the search bar if it has not been deleted.
Summary
In summary, it is important to know how WordPress uses its search system because if users are not able to easily find what they are searching for, they will move on to a different location, most likely a different website. That is not good news for improving traffic on a website, or time spent on website! Knowing how the search system works, and what can be altered by custom code, or a plugin can help improve search results and the user experience. I continue to be amazed at how many plugins might be used to improve WordPress functionality and am grateful to be learning how to do some of that without the use of plugins given their risk. I look forward to seeing how I will be able to improve our business WordPress website over the break. I also look forward to seeing how this all functions on more of an enterprise website, such as the UWSP website.