1
我目前使用此代碼只顯示當前類別的子項正在查看 -如何更改wp_dropdown_categories中'選項'和'選擇'的值?
<?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
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);
?>
問題是下拉式不顯示任何類別/術語,我錯過了什麼?