0

我正在使用此代码进行查询,但它总是返回主页,我希望任何人都可以帮助我。

$taxonomies_to_search = array(
'type' => 'Type',
'status' => 'Status',
'location' => 'Location',   
'general_status' => 'General Status',
);

$tax_query = array(
    'relation' => 'AND',
);

foreach ($taxonomies_to_search as $t => $l) {
    $var_name = 'dp_'. $t;
    $entradas_term_obj = get_term_by( 'slug', utf8_encode($_GET[$var_name]), $t);

if(isset($_GET[$var_name])){
    if ($_GET[$var_name] != "0") {
        $tax_query[] = array(
            'taxonomy' => $t,
            'field' => 'id',
            'terms' => icl_object_id($entradas_term_obj->term_id, $t, true)
        );
    }
  } 
}   

$search_values = array(
'post_type' => 'machines',
'tax_query' => $tax_query,
'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1,
'showposts' => 999,
);

$mode = 'search';        

global $wp_query;

$existing_query_obj = $wp_query;
$wp_query = new WP_Query( $search_values ); 

如您所见,我使用 WPML 进行翻译。

谢谢

4

0 回答 0