Answer the question
In order to leave comments, you need to log in
How to get all taxonomies of a post?
Please tell me how to get all taxonomies of a post into an array of the form [taxonomy name]=>[id of the term to which the post is attached]
I try using wp_get_post_terms, but something went wrong ..
$taxonomies = array('estate_district', 'estate_type', 'estate_building_type', 'estate_operation', 'estate_class');
foreach ($taxonomies as $tax) {
$taxes_list = wp_get_post_terms($estate_id, $tax, array("fields" => "ids"));
foreach($taxes_list as $tax_id => $id){ print $tax.' = '.$id; }
}
Answer the question
In order to leave comments, you need to log in
It seems to me that it should be something like this:
foreach( $taxes_list as $tax_id => $id ){ print $tax_id . ' = ' . $id; }
$taxonomies = array('estate_district', 'estate_type', 'estate_building_type', 'estate_operation', 'estate_class', 'estate_proprietor');
foreach ($taxonomies as $taxonomy) {
$est_cat = wp_get_post_terms($estate_id, $taxonomy, array("fields" => "ids"));
foreach ($est_cat as $cat => $cat_id) { $estate_object_data[$taxonomy] = $cat_id }
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question