我需要知道如何获取当前分类法的子/孙术语,并将其放入下拉列表中,以便为选项添加值。
我当前正在使用此代码精确显示我想要的内容,但我无法修改下拉列表中的选项-
<?php
//first get the current term
$current_term = get_term_by( \'slug\', get_query_var( \'term\' ), get_query_var( \'taxonomy\' ) );
//then set the args for wp_dropdown_categories
$args = array(
\'child_of\' => $current_term->term_id,
\'taxonomy\' => $current_term->taxonomy,
\'hide_empty\' => 0,
\'hierarchical\' => true,
\'depth\' => 2,
\'title_li\' => \'\',
\'show_option_all\' => All,
\'hide_if_empty\' => true
);
wp_dropdown_categories( $args );
?>
我使用的另一个代码,我需要它看起来像或类似-<?php
$terms = get_terms("videoscategory");
$count = count($terms);
if ( $count > 0 ){
echo "<select id=\'filter-select2\' style=\'width:225px;\'>";
echo "<option value=\'*\' data-filter-value=\'\' class=\'selected\'>All items</option>";
foreach ( $terms as $term ) {
echo "<option value=\'.{$term->slug}\'>" . $term->name . "</option>";
}
echo "</select>";
}
?>
因此,基本上我要寻找的是一种添加“value=\'.{$term->slug}\' “到显示子术语的第一个代码的选项。您知道如何修改上面的任一代码,以便将术语名称作为值添加到子类别的下拉列表中吗?”?