Created
May 17, 2020 23:56
-
-
Save rochow/72e412f2141e870151ba20d039795152 to your computer and use it in GitHub Desktop.
WooCommerce Optimisation - No Empty Searches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Don't allow blank searches (too intensive) | |
add_action( 'init', function() { | |
if( isset( $_GET['s'] ) && '' == $_GET['s'] && !is_admin() ) { | |
wp_redirect( site_url() ); | |
exit; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment