In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the method of disabling WordPress foreground search function, which has certain reference value, and friends who need it can refer to it. I hope you all have a lot to gain after reading this article. Let's take a look at it together.
WordPress comes with a weak and inefficient search function, and if someone takes advantage of this flaw to initiate a lot of search requests, your server is likely to go down. We can use Baidu, 360, etc. to achieve site search, and prohibit the front desk from using WordPress's own search function, add the following code to the functions.php file of the current theme.
code
//disable WordPress foreground search function disable_search( $query, $error = true ) {if (is_search() && ! is_admin()) {$query->is_search = false;$query->query_vars['s'] = false;$query->query['s'] = false;if ( $error = true )//Error page displayed after executing search// $query->is_home = true; //Go to home page $query->is_404 = true;//Go to page 404}}add_action ( 'parse_query', 'disable_search' );add_filter( 'get_search_form', create_function( '$a', "return null;" ) );
Note:
You can choose the error page displayed after performing the search, whether to jump to 404 or the home page of the website.
Original code from the network, does not support PHP 7.2, modified to support higher versions of PHP.
Thank you for reading this article carefully, I hope Xiaobian shares the method of disabling WordPress foreground search function to help everyone, but also hope that everyone supports more, pay attention to industry information channels, find problems, detailed solutions waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.