Skip to content

Instantly share code, notes, and snippets.

@pbov
Last active October 6, 2022 23:24
Show Gist options
  • Save pbov/3e2f7d2232f15a11f18c56c75ef50bf6 to your computer and use it in GitHub Desktop.
Save pbov/3e2f7d2232f15a11f18c56c75ef50bf6 to your computer and use it in GitHub Desktop.
WP Divi: remove query parameters when using search module
// 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