Skip to content

Instantly share code, notes, and snippets.

@diviengine
Last active April 29, 2022 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diviengine/02d0601d33826c309c5e7ccbaf1d4c7d to your computer and use it in GitHub Desktop.
Save diviengine/02d0601d33826c309c5e7ccbaf1d4c7d to your computer and use it in GitHub Desktop.
<script>
jQuery(document).ready(function($){ // wait for jQuery to load
// dynamically add the input below the search box that tells the search that the post type to search are products.
$(".et-search-form").append('<input type="hidden" name="post_type" value="product" />');
// now for each search box from the Divi module
$(".et_pb_menu__search-form").each(function() {
$(this).append('<input type="hidden" name="post_type" value="product" />');
});
// now for each search box from the Divi theme builder header
$(".et_pb_searchform").each(function() {
$(this).find('div').append('<input type="hidden" name="post_type" value="product" />');
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment