Avatar of Bruce Gust
Bruce Gust
Flag for United States of America asked on

How can I change the way search results are listed in Woo Commerce?

I'm using WooCommerce as a directory and I want the search results to show up differently.

Right now, when you do a search, you get this:

Rather than saying, "Products," I'd like it to say, "Resources." How can I change that?



Avatar of undefined
Last Comment
Bruce Gust

8/22/2022 - Mon
Randy Downs

See if this helps. In the form below. It looks like the code is echoing 'Search Products…' but I don't see that in your example. You could try changing Products to Resources but I would be cautious & maybe copy the line input line or the entire form and comment it out before making the change on the copy.

Open in new window

<form role="search" method="get" class="woocommerce-product-search" action="<?php echo esc_url( home_url( '/'  ) ); ?>">

   <label class="screen-reader-text" for="s"><?php _e( 'Search for:', 'woocommerce' ); ?></label>

   <input type="search" class="search-field" placeholder="<?php echo esc_attr_x( 'Search Products&hellip;', 'placeholder', 'woocommerce' ); ?>" value="<?php echo get_search_query(); ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label', 'woocommerce' ); ?>" />

   <input type="submit" value="<?php echo esc_attr_x( 'Search', 'submit button', 'woocommerce' ); ?>" />

   <input type="hidden" name="post_type" value="product" />



When using English language and you want to change to a different English string.
This is the way to do using a simple snippet code see the examples from this page
Based on their example just replace to use it with the correct string
case 'Products' : 
      $translated = 'Ressources';

Open in new window

When you need to change a string that is not in English you can simply use Poedit to edit the language file

*Note: You may need to changer other relates strings that contain the word you changed...
Bruce Gust

Thank you, gentlemen!

Here's what I did:

I couldn't figure out how to eliminate the "Products" dynamic on the default tooltip, even with your suggestions, but...

...your input inspired a different direction and it turned out to be a winner.

I disabled the search icon using the Theme's option and then I installed a plugin that searched the Woo Commerce catalog only. I could dictate how the results were displayed with that approach.

As far as the default functionality, I downloaded another plugin that allowed me to attach an image to a menu item. I used the conventional magnifying glass and attached the link that opened up a search page. The page displays whatever the user is looking for without the headings that were my nemesis in the tooltip.

So, I may have taken the long way around to get it done, but I was able to make it happen!

Thanks for your help!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Bruce Gust

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.