我会保持这个超级简洁的正常搜索工作得很好,但当我为其他功能添加了一些复选框等时,tax\\u查询不起作用,但我知道$\\u GET正在工作,因为我已将结果输出到页面左上角进行测试。
实时站点:http://costaricalifestyleproperties.com.s221952.gridserver.com/
if(!empty($_GET[\'ct_lifestyle\'])) {
//if(is_array($_GET[\'feature\'])) {
$ct_lifestyle = $_GET[\'ct_lifestyle\'];
foreach ($ct_lifestyle as $lifestyle):
$search_values[\'tax_query\'] = array (
\'taxonomy\' => \'lifestyle\',
\'field\' => \'slug\',
\'terms\' => $lifestyle,
\'operator\' => \'IN\'
);
echo $lifestyle;
endforeach;
//}
}我为测试注释掉了is\\u array(),可以选择一个复选框而不是多个复选框。自定义分类法也可以使用,我对名称进行了双重和三重检查。下面是寄存器函数。
非常感谢您的帮助,我已经绞尽脑汁了好几个小时,我知道这一定是我错过的简单的东西。
如果(!function\\u exists(\'ct\\u lifestyle\\u taxonomies\')){
add_action( \'init\', \'ct_lifestyle_taxonomies\', 0 );
function ct_lifestyle_taxonomies() {
// Lifestyle
$lifestylelabels = array(
\'name\' => __( \'Lifestyle\', \'contempo\' ),
\'singular_name\' => __( \'Lifestyle\', \'contempo\' ),
\'search_items\' => __( \'Search Lifestyles\', \'contempo\' ),
\'popular_items\' => __( \'Popular Lifestyles\', \'contempo\' ),
\'all_items\' => __( \'All Lifestyles\', \'contempo\' ),
\'parent_item\' => null,
\'parent_item_colon\' => null,
\'edit_item\' => __( \'Edit Lifestyle\', \'contempo\' ),
\'update_item\' => __( \'Update Lifestyle\', \'contempo\' ),
\'add_new_item\' => __( \'Add New Lifestyle\', \'contempo\' ),
\'new_item_name\' => __( \'New Lifestyle Name\', \'contempo\' ),
\'separate_items_with_commas\' => __( \'Separate Lifestyles with commas\', \'contempo\' ),
\'add_or_remove_items\' => __( \'Add or remove Lifestyles\', \'contempo\' ),
\'choose_from_most_used\' => __( \'Choose from the most used Lifestyles\', \'contempo\' )
);
register_taxonomy( \'lifestyle\', \'listings\', array(
\'hierarchical\' => false,
\'labels\' => $lifestylelabels,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'lifestyle\' ),
));
if(!function_exists(\'lifestyle\')) {
function lifestyle() {
global $post;
global $wp_query;
$terms_as_text = strip_tags( get_the_term_list( $wp_query->post->ID, \'lifestyle\', \'\', \', \', \'\' ) );
echo esc_html($terms_as_text);
}
}
}
}