In every WordPress website, there is an inbuilt search system by default, and that is part of the usefulness of a Content Management System (CMS) like WordPress. However, not all websites require a search feature, especially simple corporate branding websites that do not have more than 10 pages.
You may think that it's fine not to do anything about the default search feature if you just remove the search form from your website. No search form means no search queries, right?
That's not true. In our years of building WordPress websites as a web design agency in Singapore, we've come to realise that it is still possible for search queries to be made without having an on-page search form. In WordPress, if your website is example.com, then you can make a search query on 'WordPress development' by using this URL:
In fact, we have seen search query URLs showing up in Google Analytics even when we do not have the search form on display. This is most prominent for WordPress websites that used to have the search form, but upon a web revamp, have had the search form removed.
In fact, if you just run the URL search parameter on a few WordPress websites, you may be surprised to find out how often web designers and web developers overlook the search page.
Hence, be it for an aesthetic point of view, or from an architectural coding point of view, we should not forget to disable the search page if we do not need it on our WordPress website. Likewise, if we do have the search form somewhere on our website, it is important that we do not forget to style it properly. If you realise that you have overlooked it and you need help styling a WordPress search page or search form, please feel free to contact us.
If you just want to disable your WordPress search feature altogether, you can use this script:
This script does 3 things:
- Disable the search query and redirect all search queries to 404
- Disable the search form
- Remove the search widget
Paste the above script into your functions.php (you do not need to edit anything in the script). If you do not know where in your functions.php you should insert this script, just paste it at the very bottom.
Unsure of where to insert this? Don’t want to break anything? Our team of WordPress developers in Singapore can accomplish this job for you safely and efficiently. We are highly experienced in WordPress and web development and are equipped in solving any issues you might be facing.
Do note that this guide is purely for enqueuing external scripts on WordPress. For other WordPress functions, please contact us if you need help. Our team of WordPress developers in Singapore will be happy to assist you!