How to restrict the search fields for a specific post type

I figured it out, thanks function my_search_pre_get_posts($query) { if($query->query_vars[‘s’] != ” && is_search()) { if(absint($query->query_vars[‘s’])) { $query->set(‘p’, $query->query_vars[‘s’]); $query->set(‘post_type’, [‘property’]); // Reset the search value $query->set(‘s’, ”); } } } // Filter the search page add_filter(‘pre_get_posts’, ‘my_search_pre_get_posts’); A very good learning of WordPress functionality.

WP_Query tax query part of slug

You can use below code to search in taxonomy. First using name__like in get_terms it will return all terms ids which have $keyword then that ids use in wp_query. $termIds = get_terms([ ‘name__like’ => $keyword, ‘fields’ => ‘ids’ ]); $args = [ ‘post_type’ => ‘movies’, ‘tax_query’ => [ [ ‘taxonomy’ => ‘actors’, ‘field’ => ‘id’, … Read more