Traditional Search without JavaScript
Explore how to implement a traditional search in WordPress without relying on JavaScript. Understand how to create a search form, customize page templates, and generate search URLs that use the built-in WordPress search functionality. This lesson helps you make your site accessible to users without JavaScript and ensures a reliable fallback search experience.
Search functionality without JavaScript
In this lesson, we will create a non-JavaScript search. We have implemented the live search feature using JavaScript. But there may be some users who do not have JavaScript enabled on their devices. A network or internet connection issue may also prevent JavaScript from the website from downloading. Traditional search is a fallback option for such users. If a user clicks the search icon in the absence of JavaScript, they will be taken to the traditional non-JavaScript search page.
The non JavaScript search relies on the built-in search functionality offered by WordPress. To search for a term, we can append ?s=search-term at the end of the website’s root URL, where s stands for search.
Say, we want to search for the term career. Type ?s=career at the end of the root URL and we are taken to a search results page. This page shows all results that match the search string. WordPress uses a file search.php for displaying the search resutls page. In the absence of this file, index.php is used as the fallback opinion. We ...