Reputation: 15
I am using a dynamix wordpress theme for new blog post website, when I try to filter posts, in the result page it is showing all the posts. I used many plugins as well to filter posts. such as search & filter and MDTF. still in the search result page it is showing all the available posts
Upvotes: 1
Views: 632
Reputation: 336
Put below code in function.php file and your replace your posttype
function searchfilter($query) {
if ($query->is_search) {
$query->set('post_type', array( 'your-custom-post-type-name' ) );
}
return $query;
}
add_filter('pre_get_posts','searchfilter');
Upvotes: 2