Are you developing a WordPress website in which you don’t want to have the search features or don’t want to allow your website visitor’s to search anything on your website, then this tutorial is designed for you, keep your close attention in this post as I am going to share how to disable search features in WordPress.
This is very simple & easy you need to only add the below filters at the end of the wp-content/themes/your-theme-folder/functions.php file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | function fb_filter_query( $query, $error = true ) { if ( is_search() ) { $query->is_search = false; $query->query_vars[s] = false; $query->query[s] = false; //If get any 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;" ) ); |
Hope this will help you, please share your thought about this tutorial in this below comment sections and do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: remove search in wordpress, wordpress search, wordpress tuto, wordpress tutorial, wordpress tutorial for beginner, wordpress tutorial for beginners, wordpress tutorials, wordpress tutorials for beginners, wordpress tutorils