我使用以下代码从自定义分类法中获取记录。
if ($_GET[\'post_type\'] == "developments"){ ?>
<?php
global $wp_query;
$paged = $wp_query->query_vars[\'paged\'];
$development_args = array(
\'post_type\' => $_GET[\'post_type\'],
\'orderby\' =>\'title\',
\'order\' => \'ASC\',
\'posts_per_page\' => 14,
\'paged\' => $paged,
\'s\' => $_GET[\'search_building_name\'],
);
$development_args[\'meta_query\'] = array(
\'relation\'=>\'AND\',
array(
\'key\' => \'total_units\',
\'type\' => \'numeric\',
\'value\' => $_GET[\'search_total_units\'],
\'compare\' => $_GET[\'total_units_operator\']
),
array(
\'key\' => \'total_floors\',
\'type\' => \'numeric\',
\'value\' => $_GET[\'search_total_floors\'],
\'compare\' => $_GET[\'total_floors_operator\']
),
);
$development_args[\'tax_query\'] = array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'type\',
\'field\' => \'slug\',
\'terms\' => $_GET[\'search_type\'],
//\'operator\' => \'AND\'
),
array(
\'taxonomy\' => \'amenities\',
\'field\' => \'slug\',
\'terms\' => $_GET[\'search_amenities\'],
\'operator\' => \'AND\'
),
array(
\'taxonomy\' => \'style\',
\'field\' => \'slug\',
\'terms\' => $_GET[\'search_style\'],
\'operator\' => \'AND\'
),
);
if ($_GET[\'search_neighborhood\'] != \'any\'){
$development_args[\'tax_query\'][] = array(
\'taxonomy\' => \'neighborhood\',
\'field\' => \'slug\',
\'terms\' => $_GET[\'search_neighborhood\'],
);
}
if ($_GET[\'search_developer\'] != \'any\'){
$development_args[\'tax_query\'][] = array(
\'taxonomy\' => \'developer\',
\'field\' => \'slug\',
\'terms\' => $_GET[\'search_developer\'],
);
}
if ($_GET[\'search_architect\'] != \'any\'){
$development_args[\'tax_query\'][] = array(
\'taxonomy\' => \'architect\',
\'field\' => \'slug\',
\'terms\' => $_GET[\'search_architect\'],
);
}
if ($_GET[\'search_delivered\'] != \'any\'){
$development_args[\'tax_query\'][] = array(
\'taxonomy\' => \'delivered\',
\'field\' => \'slug\',
\'terms\' => $_GET[\'search_delivered\'],
);
}
query_posts($development_args );
}
$wp\\u query->post\\u count返回10,即使实际记录数要多得多。我尝试过各种解决方案,但没有一种对我有效。这个问题可能是重复的,但我再次问这个问题,因为即使是一些答案对其他人也有用,但没有一个能给出很好的解释。谢谢