add_filter( "posts_where", function($where, $query){ global $wpdb; if ( isset( $query->query_vars['OR_sku_filter'] ) ) { $like = "%" . $wpdb->esc_like( $query->query_vars['OR_sku_filter'] ) . "%"; $where .= " OR ({$wpdb->posts}.ID IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE {$wpdb->postmeta}.meta_key = '_barcode' AND {$wpdb->postmeta}.meta_value LIKE '" . $like . "' ))"; } return $where; }, 10, 2 );
Search products by custom field "_barcode" Print
Created by: Alex Prokaev
Modified on: Mon, 7 Oct, 2019 at 10:04 AM
Did you find it helpful? Yes No
Send feedbackSorry we couldn't be helpful. Help us improve this article with your feedback.