[php] /* adding SKUs to default WP search BEGIN */ function search_by_sku( $search, $query_vars ) { global $wpdb; if(isset($query_vars->query['s']) && !empty($query_vars->query['s'])){ $args = array( 'posts_per_page' => -1, 'post_type' => 'product', 'meta_query' => array( array( 'key' => '_sku', 'value' => $query_vars->query['s'], 'compare' => 'LIKE' ) ) ); $posts = get_posts($args); if(empty($posts)) return $search; $get_post_ids = array(); foreach($posts as $post){ $get_post_ids[] = $post->ID; } if(sizeof( $get_post_ids ) > 0 ) { $search = str_replace( 'AND (((', "AND ((({$wpdb->posts}.ID IN (" . implode( ',', $get_post_ids ) . ")) OR (", $search); } } return $search; } add_filter( 'posts_search', 'search_by_sku', 999, 2 ); /* adding SKUs to default WP search END */ [/php]
Home
A full service web design company.
Portfolio
Responsive mobile ready web designs.
Pricing
Budget ranges for a website design.
Hosting
Recommended web host companies.
Reviews
Real Reviews from real clients.
Services
Website design services.
The Process
The web design process according to Divi Guy.
About
Who is the Divi Guy?
Logo Design
Logos I've made over the years.
Contact
Contact the Divi Guy now.
0 Comments