我很难从自定义分类法中查询具有多个标记的帖子。例如,如果我有一篇名为“草莓拼接”的帖子,它有膳食类型(自定义分类)“无麸质”和“饮料”
当我筛选帖子以查找“无麸质”时,会显示“草莓拼接”,但当我搜索“饮料”时,却没有任何结果。我的问题只是看第一个术语。
看看http://jimalie.com.au/recipes/
这是我生成自定义分类法的部分代码:
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'show_in_nav_menus\' => true,
\'show_ui\' => true,
\'show_tagcloud\' => true,
\'show_admin_column\' => false,
\'hierarchical\' => false,
\'rewrite\' => true,
\'query_var\' => true
);
register_taxonomy( \'meal_types\', array(\'recipes\'), $args );
这是我的查询代码:
$mealtype = $_POST[\'mealtype\'];
$args = array(\'post_type\' => \'recipes\', \'meal_types\' => $mealtype, \'paged\' => $paged);
我从动态填充的下拉列表中获得$mealtype:
$terms = get_terms( \'meal_types\' );
$count = count($terms);
if ($count > 0) {
foreach ($terms as $term) { ?>
<option value="<?php echo $term->name; ?>" <?php if($_POST[\'mealtype\'] == $term->name) { echo \'selected\'; } ?>><?php echo $term->name; ?></option>
<?php }
}
我的查询:
$wp_query = new WP_Query( $args );
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) : $wp_query->the_post();
整个模板的代码:
http://pastebin.com/5e07FMJm我怎样才能看到所有的条款?