
Do you want to disable the search feature in WordPress blog? There’s a simple way to do it. Most folks will choose WordPress for creating their blog or website. but the fact is nobody knows the WordPress search feature can be disabled! Well, we are going to show you a step by step guide for disabling the search feature in WordPress.
Why Do You Need To Disable Search Feature?
As I said, most website owners are using WordPress for creating their websites. This can be one-page WordPress websites or business websites. You know these type websites do not need any search feature there. In that case, the feature must be in disabled format.
How To Disable The Search Feature In WordPress
At this time, there are 2 methods.
- Plugin Method – Which is very simple.
- Coding Method – Just need to add some codes to the theme’s functions file.
if you are a guy who changes theme recently, we recommend you going with the plugin method. If you are stick with any WordPress theme and receives updates only, we recommend you to create a child theme and add the code in the functions file.
We are going to show you both methods below.
Disable Search Using Plugin
First of all, go to your WordPress dashboard and add new plugins section. There, you need to search for the Disable Search plugin. Simply install it to your blog.
Now, activate it.
You are done! The plugin doesn’t need any additional configuration. Simply activate it on your blog to disable the search feature. All the added search widget will disappear from your blog.
Disable Search Using Code
Don’t want to use more plugins? Well here’s the code to disable the feature. Copy the below code, paste it on your child theme’s functions file and update the file.
function fb_filter_query( $query, $error = true ) { if ( is_search() ) { $query->is_search = false; $query->query_vars[s] = false; $query->query[s] = false; // to error if ( $error == true ) $query->is_404 = true; } } add_action( 'parse_query', 'fb_filter_query' ); add_filter( 'get_search_form', create_function( '$a', "return null;" ) );
All added search widgets will be removed after adding this code.
NOTE: In some cases, the code will conflict with other theme functions and specific plugins. If you are experiencing any issues with the code, we recommend you choose the plugin method. It will work with most WordPress themes without getting any error.
This is how you can disable the search feature in WordPress. We hope you enjoyed the read and found it useful. If you did, please consider sharing this post with your friends and fellow bloggers on social media.
For more related posts, you may want to check out our blog section.
Leave a Reply