Last active
October 6, 2022 23:24
-
-
Save pbov/3e2f7d2232f15a11f18c56c75ef50bf6 to your computer and use it in GitHub Desktop.
WP Divi: remove query parameters when using search module
This file contains 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
// the search module of divi adds some hidden fields into the search form, | |
// so you get some (maybe) unwanted additional queries in your search result url. | |
// field names and values may vary depending on module settings | |
function remove_hidden_fields_from_search_module($output, $tag) { | |
// only for Divi search module | |
if ($tag === 'et_pb_search') { | |
// remove hidden fields | |
$output = preg_replace('/<input type="hidden" name="et_pb_searchform_submit" value="et_search_proccess" \/>/', '', $output); | |
$output = preg_replace('/<input type="hidden" name="et_pb_include_posts" value="yes" \/>/', '', $output); | |
$output = preg_replace('/<input type="hidden" name="et_pb_include_pages" value="yes" \/>/', '', $output); | |
} | |
return $output; | |
} | |
add_filter('do_shortcode_tag', 'remove_hidden_fields_from_search_module', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment