Skip to content

Instantly share code, notes, and snippets.

@DWboutin
Created July 31, 2013 17:44
Show Gist options
  • Save DWboutin/6124303 to your computer and use it in GitHub Desktop.
Save DWboutin/6124303 to your computer and use it in GitHub Desktop.
Trouver toutes les taxonomies Wordpress
<?php
$args = array(
'orderby' => 'term_id',
'order' => 'ASC',
'hide_empty' => 0,
);
$product_categories = get_terms( 'product_cat', $args );
$menuCat = array();
foreach($product_categories as $cat){
if(!array_key_exists($cat->parent,$menuCat) && $cat->parent !== 0){
$menuCat[$cat->term_id]['name'] = $cat->name;
$menuCat[$cat->term_id]['link'] = get_term_link($cat);
}else{
$menuCat[$cat->parent]['children'][$cat->term_id]['name'] = $cat->name;
$menuCat[$cat->parent]['children'][$cat->term_id]['link'] = get_term_link($cat);
}
}
print_r($menuCat);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment