【发布时间】:2019-03-27 12:57:36
【问题描述】:
似乎无法弄清楚在下拉列表中显示 woocommerce 产品类别的第二级的方式。
到目前为止我有这个
function lvl_1()
{
$args = array(
'show_option_all' => ' ',
'name' => 'Marka',
'taxonomy' => 'product_cat',
'orderby' => 'name',
'show_count' => 0,
'pad_counts' => 0,
'hierarchical' => 1,
'hide_empty' => 0,
'parent' => 0,
);
$lvl_1_categories = wp_dropdown_categories( $args );
}
function lvl_2()
{
$args = array(
'taxonomy' => 'product_cat',
'parent' => 0,
);
$lvl_1_categories = get_categories( $args );
$args2 = array(
'show_option_all' => ' ',
'name' => 'Modelis',
'taxonomy' => 'product_cat',
'orderby' => 'name',
'show_count' => 0,
'pad_counts' => 0,
'hierarchical' => 1,
'hide_empty' => 0,
// Somewhere here i should get a value of first level elements to dispaly their childer, thats what i think.
);
$lvl_2_categories = wp_dropdown_categories( $args2 );
}
lvl_1 函数工作正常,它显示顶级类别,但有没有办法用这个wp_dropdown_categories() 函数显示第二级类别?
【问题讨论】:
标签: wordpress woocommerce