Articles of wp get object terms

How to order the get_categories result

I read the documentation of the codex but i can’t order the get_categories() result just like parent,childrens. I have these kind of categories’ three: -Events – Music – Culture – Workshop – Tourism -Sport -Football -Rugby -Tennis I want the output to be: Events, Music I tried: echo $product->get_categories(); and the results is the print […]

Reduce / optimize calling of wp_get_object_terms() when generating permalinks

My theme runs a loop that does not require post terms to show. However WordPress core runs the wp_get_object_terms function on every iteration. This results in unnecessary DB queries such as: SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = […]

wp_get_object_terms – How can I order the resulting array by hierarchy?

I’m returning a custom hierarchal taxonomy via wp_get_object_terms. The trouble is that the results are being ordered by name or count, neither of which are proving reliable. (I’m using a custom taxonomy for “Location” – City, State, Country – sometimes the State appears before the City) Is there a way I can order the resulting […]

Sort get_users by custom field

I have a custom USER taxonomy called ‘label’ which also has a custom field of ‘sort_order’ – I am trying to return a list of users that have the label taxonomy and then sort this list by the sort_order field. So far I have….. <?php $users = get_users( array( ‘meta_key’ => ‘sort_order’, ‘fields’ => ‘all_with_meta’ […]

wp_get_object_terms() to get a list of all the terms attached to all the posts in the current query

How can I use wp_get_object_terms() to get a list of all the terms attached to all posts in the current query? For example, for the current query I want to get an array of the terms from the “Alfa” taxonomy that are contained in all the queried posts. wp_get_object_terms($wp_query, ‘alfa’); But that only seems to […]

Get the the top-level parent of a custom taxonomy term

How would I get the top-level parent of a given term? I am using wp_get_object_terms to get taxonomy terms on posts, but instead of showing all tagged terms, I only want to show tagged terms’ top-level parents. So if these are my selected terms, I only want to show Breakfast, Lunch and Dinner. x BREAKFAST […]