Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function custom_search( $query ) {
- if( ! is_admin() && $query->is_main_query() ) {
- if ( $query->is_search() ) {
- $meta_query = $query->get( 'meta_query' );
- $meta_query[] = array(
- 'key' => 'product_code',
- 'value' => $query->query['s'],
- 'compare' => 'LIKE'
- );
- $query->set( 'meta_query', $meta_query );
- }
- }
- }
- add_action( 'woocommerce_product_query' , 'custom_search' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement