【发布时间】:2026-01-26 10:20:04
【问题描述】:
我正在使用 wp_dropdown_categories() 函数来显示类别下拉列表。我正在传递以下数组参数以在选项值中显示分类 slug。
'value_field' => 'slug',
但我面临与选项值相关的问题。它显示分类 ID 而不是 slug。
$category_args = array(
'show_option_none' => 'Category',
'hide_empty' => 0,
'hierarchical' => TRUE,
'name' => 'selected_category',
'taxonomy' => 'taxonomy_name',
'value_field' => 'slug',
);
// Display or retrieve the HTML dropdown list of job category
wp_dropdown_categories( $category_args );
对这个问题有任何想法吗?任何帮助将不胜感激。
谢谢
【问题讨论】: