Php 将类别添加到默认WordPress搜索

Php 将类别添加到默认WordPress搜索,php,mysql,wordpress,categories,Php,Mysql,Wordpress,Categories,我有一个包含选择字段的搜索表单。前两个用自定义分类法填充,第三个用默认的wordpress分类法填充。当仅将前两个用于查询时,效果良好。当我使用第三个(类别)时,搜索查询只会忽略该字段,并得到相同的结果。我怎样才能解决这个问题 我使用了这些函数使它们工作: function ftiaxnospiti_filter_search($query) { if ( is_admin() || ! $query->is_main_query() ) { return; } if

我有一个包含选择字段的搜索表单。前两个用自定义分类法填充,第三个用默认的wordpress分类法填充。当仅将前两个用于查询时,效果良好。当我使用第三个(类别)时,搜索查询只会忽略该字段,并得到相同的结果。我怎样才能解决这个问题

我使用了这些函数使它们工作:

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

  if ( $query->is_search ) {
    $query->set( 'post_type', array('post', 'seller') );
    }

  return $query;
};
add_action('pre_get_posts', 'ftiaxnospiti_filter_search');

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

  if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
    // Get all your post types
    $post_types = array( 'post', 'seller' );

    $query->set( 'post_type', $post_types );
  }

  return $query;
}
add_action( 'pre_get_posts', 'ftiaxnospiti_add_custom_types_to_tax' );