Traditional Search without JavaScript

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 can see that the search results are displayed using the format of a blog post and the banner title says School of Excellence Blogs.

Get hands-on with 1200+ tech skills courses.