Monday, May 23rd, 2016
Paste this in to your functions.php file – this assumes your CPT is called ‘products’
add_filter( 'posts_search_orderby', function( $search_orderby ) {
global $wpdb;
return "{$wpdb->posts}.post_type LIKE 'products' DESC, {$search_orderby}";
});
Tags: CPT, Custom post type, Posts, Results, Search, WordPress
Posted in PHP, WordPress | No Comments »