Mik*_*ike 2 php wordpress get categories woocommerce
I am calling a list of Woocommerce categories and am trying to get them to show in the custom, darg-and-drop, order that they have been organised in but to no avail. The usual 'orderby' => 'menu_order' isn't working. Code below:
<?php
$args=array(
'orderby' => 'menu_order',
'order' => 'ASC',
'child_of' => 13,
'hide_empty' => 0,
'taxonomy' => 'product_cat'
);
$categories=get_categories($args);
foreach($categories as $category) {
echo "<li class='filter-option " . $category->slug . "'><a href='#' data-filter-value='." . $category->slug . "'>";
echo $category->name;
echo "</a></li>";
}
?>
Run Code Online (Sandbox Code Playgroud)
Any help would be greatly appreciated
您正在寻找get_categories()参数的参数是
'menu_order' => 'asc'
Run Code Online (Sandbox Code Playgroud)
所以例如 我的函数返回前三个Woocommerce根目录类别(不包括未分类的类别),如下所示:
'menu_order' => 'asc'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6234 次 |
最近记录: |