Automattic\WooCommerce\Admin\API
Coupons::add_wp_query_search_code_filter()
Add code searching to the WP Query
Method of the class: Coupons{}
No Hooks.
Return
String
.
Usage
$result = Coupons::add_wp_query_search_code_filter( $where, $wp_query );
- $where(string) (required)
- Where clause used to search posts.
- $wp_query(object) (required)
- WP_Query object.
Coupons::add_wp_query_search_code_filter() Coupons::add wp query search code filter code WC 8.7.0
public static function add_wp_query_search_code_filter( $where, $wp_query ) { global $wpdb; $search = $wp_query->get( 'search' ); if ( $search ) { $code_like = '%' . $wpdb->esc_like( $search ) . '%'; $where .= $wpdb->prepare( "AND {$wpdb->posts}.post_title LIKE %s", $code_like ); } return $where; }