I am currently using this code to display only the child terms of the current category being viewed -
<?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 );
?>
I need to be able to add values and classes to the 's and the opening . How can I modify the above code to do so?
Im not sure but I think Im getting close. -
<?php
function get_terms_dropdown($taxonomies, $args){
//first get the current term
$current_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$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
);
$output ="<select name='".$term_slug."'><option selected='".$selected."' value='".$emptyvalue."'>Select a Category</option>'";
foreach($current_term as $term){
$output .="<option name='".$term_slug."' value='".$link."'>".$term_name."</option>";
}
$output .="</select>";
return $output;
}
echo get_terms_dropdown($taxonomies, $args);
?>
The problem is the drop down is not showing any categories/terms, what am I missing?