Created
December 5, 2022 20:28
-
-
Save pattonwebz/6fa4bbbc7fc0a6c6e86282715321cbbf to your computer and use it in GitHub Desktop.
Disable core search query handling
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 | |
| function disable_core_search_query_handling($query, $error = true) { | |
| if (is_search() && !is_admin()) { | |
| $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', __NAMESPACE__ . '\disable_core_search_query_handling'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment