vendredi 30 janvier 2015

Display sub categories and their data of a taxonomy


I want to output the sub category details of a taxonomy



$getTerms = get_terms($taxonomy, $args);
print_r($getTerms);


When i print the above out it returns the object. But theres no value difference between parent and sub categories. The first is a parent taxonomy and the second is a sub-category.



[1] => stdClass Object
(
[term_id] => 23
[name] => Corporate teams
[slug] => corporate-teams
[term_group] => 0
[term_taxonomy_id] => 23
[taxonomy] => team_names
[description] => Description of corporate team
[parent] => 0
[count] => 0
[image_id] => 0
)

[3] => stdClass Object
(
[term_id] => 25
[name] => Team name 1
[slug] => team-name-1
[term_group] => 0
[term_taxonomy_id] => 25
[taxonomy] => team_names
[description] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nec pellentesque sapien.
[parent] => 22
[count] => 1
[image_id] => 90
)


How would i query part of this object (likely as a foreach or as a WP_Query) so it will return the sub categories and their relavant values (title, image,etc)? Is the 'get_terms()' function the right way to go for this?





Aucun commentaire:

Enregistrer un commentaire