how can i restrict the saerch fields only for specific post type

Question

I used this code on functions.php

function searchfilter($query) { 
    if ( is_admin() || ! $query->is_main_query() ){return;}

    if( $query->is_main_query()  ) {
       $query->set( 'post_type', ['property']);
     }   
     return $query;
 }   
add_filter('pre_get_posts','searchfilter');
0
, Michael 3 years 2019-12-04T04:02:11-05:00 0 Answers 83 views 0

Leave an answer

Browse
Browse