I read the documentation of the codex but i can't order the get_categories() result just like parent,childrens.
I have these kind of categories' three:
-Events
- Music
- Culture
- Workshop
- Tourism
-Sport
-Football
-Rugby
-Tennis
I want the output to be:
Events, Music
I tried:
echo $product->get_categories();
and the results is the print of Music, Events (child, parent).
I also tried putting $args as the argument get_categories():
$args = array(
'type' => 'post',
'child_of' => 0,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => 'category',
'pad_counts' => false
);
How can I order it the way I want?
$post
? Or all categories in a hierarchical manner ? – Simon Nov 29 '13 at 16:50get_categories
is not the correct function for categories assigned to a post, you wantget_the_category
for built-in category taxonomy, orget_the_terms
for any taxonomy including custom ones. – Milo Nov 29 '13 at 17:31