Make the default Divi search box search WooCommerce products only

If you have a Divi/WooCommerce site and you don’t have any posts, this is perfect for you. The default Divi search will now search only your products. You can add this to the Divi theme options Integration tab in the head. Or add to a Code module in your global header. This also changes the placeholder text from “Search” to “Search Products”. For example when you click on the search icon like below. change-search-products It will show this: change-search-products2 Make sure you put the code inside a script tag.
jQuery(document).ready(function($){ // wait for jQuery to load
  $(".et-search-form").append(''); // dynamically add the input below the search box that tells the search that the post type to search are products.
  $(".et_pb_menu__search-form").each(function() { // now for each search box from the Divi module
  $(this).append(''); // add that input there too
  });
});
// change placeholder text on default Divi search box
window.onload = function() {
let searchinput = document.getElementsByClassName('et_pb_menu__search-input')[0];
searchinput.placeholder = "Search Products";
}

Need help with this?
Hire me for a consultation and I'll walk you thru the process.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

5 star reviews
"WOW! Money WELL spent. Joseph was incredibly knowledgeable in helping me make some final tweeks to my Divi website. He was very caring and went above and beyond. Will 100% use him for any future Divi website needs."
Claire - CMMC

5 star reviews
"You really get what you pay for with Joe. He does more than simply build a website, he sets up websites for success. Functional, clean, professional designs and he keeps up/implements the latest plugins and technology. Thank you Joe. I will continue to refer you work."
Mark Winger

5 star reviews
"The best WordPress guy I’ve worked with on WordPress, hands-down (and I’ve worked with dozens). Remarkably good with theme customizations with a quick turn. Kept it on budget as well. A rarity with hourly contracts."
Nate Wright

5 star reviews
"Thanks for your prompt reply. You’re always so comprehensive. If we could write another review just for your communication skills, then we would."
Alex N

More Tips

Ask a Question

"*" indicates required fields