Restricting wordpress search only for specific post type
- by admin
- 0
function search_filter($query) { if ($query->is_search) { $query->set('post_type', 'post'); // specify slug of post type instead of this 'post' } return $query; } add_filter('pre_get_posts','
search_filter
');
function search_filter($query) { if ($query->is_search) { $query->set(‘post_type’, ‘post’); // specify slug of post type instead of this ‘post’ } return $query; } add_filter(‘pre_get_posts’,’search_filter’);
function search_filter($query) { if ($query->is_search) { $query->set(‘post_type’, ‘post’); // specify slug of post type instead of this ‘post’ } return $query; } add_filter(‘pre_get_posts’,’search_filter’);