# Change the Product Search Placeholder

> Replaces the "Search products…" hint inside WooCommerce's product search box with your own text, such as "Search 2,000 parts by name or code".

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, search, text
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-product-search-placeholder/

## Code

```php
$wpide_search_placeholder = 'Search by name or product code'; // Placeholder text.

add_filter( 'get_product_search_form', function ( $form ) use ( $wpide_search_placeholder ) {
    return preg_replace( '/placeholder="[^"]*"/', 'placeholder="' . esc_attr( $wpide_search_placeholder ) . '"', $form, 1 );
} );
```

## Notes

Affects the classic product search widget and get_product_search_form(); the Product Search block has its own placeholder setting.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Change the Product Search Placeholder" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
