我想显示我的分类法名称routine_class
和routine_type
,但我正在尝试但失败了。
我有一个网站,其中的一种自定义帖子类型属于两种分类法。搜索时,我不会显示自定义分类标准值。看到此代码。
当我有print_r($single_agrs);
时,此功能将显示此代码
routineArray ( [0] => Array ( [key] => routine_class [type] => string [value] => ষষ্ঠ [compare] => LIKE ) [1] => Array ( [key] => routine_type [type] => string [value] => পরীক্ষার রুটিন [compare] => LIKE ) )
<form method="post" class="search-form" action="">
<div class="row">
<div class="col-sm-4">
<div class="form-group">
<?php
// Routine Class term
$terms = get_terms('routine_class');
if(!empty($terms) &&!is_wp_error($terms)) { ?>
<select name="routine_class" class="selectpicker">
<option value="">- Select Class -</option>
<?php
foreach($terms as $term1) {
echo '<option value="'.$term1->name.'">'.$term1->name.'</option>';
}
?>
</select>
<?php }
?>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<?php
// Routine Class term
$terms = get_terms('routine_type');
if(!empty($terms) &&!is_wp_error($terms)) { ?>
<select name="routine_type" class="selectpicker">
<option value="">- Select Type -</option>
<?php
foreach($terms as $term2) {
echo '<option value="'.$term2->name.'">'.$term2->name.'</option>';
}
?>
</select>
<?php }
?>
</div>
</div>
</div>
<div class="col-md-12">
<div class="row"><button type="submit" class="btn btn-success">Result</button></div>
</div>
</form>
<?php
$routine_class = $_POST['routine_class'];
$routine_type = $_POST['routine_type'];
$args = array(
'post_type' => 'routine',
'meta_query' => array(
array(
'key' => 'routine_class',
'type' => 'string',
'value' => $routine_class,
'compare' => 'LIKE'
),
array(
'key' => 'routine_type',
'type' => 'string',
'value' => $routine_type,
'compare' => 'LIKE'
)
),
);
foreach ($args as $single_agrs) {
echo $single_agrs->routine_type;
//print_r($single_agrs);
}
?>
</div>