I think that the start of my problem is that parent children and grandchildren don't have the ID's in hierarchical order, the parent category was added after children categories so i have problem ordering them correctly.
I want to get the list of custom taxonomies for custom post type, for that i use the function wp_get_post_terms
to list the taxonomies. But i can't get them in order of parent
> children
> grandchildren
From the wordpress documentation this should work:
wp_get_post_terms($edit_post->ID, 'listings_category', array("fields" => "ids", "orderby" => "parent"));
But the grandchildren category is always listed before children category.
This is the categories list:
Services
-- Design
-- Artistic
But in the database their id's are not hierarchical
Services => id(454)
Design => id(43)
Artistic => id(44)
And i can't make them display in order Services
> Design
> Artistic
They always end up in different order.
Here's an array output
array(3) {
[0]=>
object(WP_Term)#7074 (10) {
["term_id"]=>
int(494)
["name"]=>
string(8) "Services"
["slug"]=>
string(8) "services"
["term_group"]=>
int(0)
["term_taxonomy_id"]=>
int(494)
["taxonomy"]=>
string(17) "listings_category"
["description"]=>
string(0) ""
["parent"]=>
int(0)
["count"]=>
int(1)
["filter"]=>
string(3) "raw"
}
[1]=>
object(WP_Term)#7073 (10) {
["term_id"]=>
int(44)
["name"]=>
string(20) "Artistic"
["slug"]=>
string(18) "artistic"
["term_group"]=>
int(0)
["term_taxonomy_id"]=>
int(44)
["taxonomy"]=>
string(17) "listings_category"
["description"]=>
string(0) ""
["parent"]=>
int(43)
["count"]=>
int(1)
["filter"]=>
string(3) "raw"
}
[2]=>
object(WP_Term)#7075 (10) {
["term_id"]=>
int(43)
["name"]=>
string(23) "Design"
["slug"]=>
string(23) "design"
["term_group"]=>
int(0)
["term_taxonomy_id"]=>
int(43)
["taxonomy"]=>
string(17) "listings_category"
["description"]=>
string(0) ""
["parent"]=>
int(494)
["count"]=>
int(1)
["filter"]=>
string(3) "raw"
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…