I have taxonomy called mh_menu. I want to get terms for object, and for it I'm using wp_get_object_terms. When I do
wp_get_object_terms(639, 'mh_menu', array('fields' => 'all',
'orderby' => 'none'));I get result with terms array
WP_Term Object
(
[term_id] => 118
[name] => new cat
[slug] => new-cat
[term_group] => 0
[term_taxonomy_id] => 118
[taxonomy] => mh_menu
[description] =>
[parent] => 0
[count] => 2
[filter] => raw
)and etc
but When I do
wp_get_object_terms(639, 'mh_menu', array('fields' => 'tt_ids',
'orderby' => 'none'));I get empty array
Array
(
)And the most interesting thing that I have two wordpress sites (all is up to date) and in first site it's working but in the second site it's returning empty array.
52 Answers
Try my code and let me know what you are getting in the count in the printed array.
wp_get_object_terms(639, 'mh_menu', array('fields' => 'tt_ids', 'orderby' => 'none','hide_empty' => false));If you found 0 than please add the post to respective category and revert your code back as this is the simple default wordpress behavior.
If your category is not map to the post wordpress default not allowing you to display that category. If you still wish to show that category than you need to pass the hide_empty as a false in your argument.
I've found the solution, the problem was from hierarchy. I've deleted whole term, and recreated, so the information for hierarchy was right, and all worked!