I have a custom taxonomy associated with the WooCommerce product post type, which I have added to the woocommerce_sortable_taxonomies
array so they can be ordered in the WordPress admin.
The plugin stores the term order in its own database table wp_woocommerce_termmeta
with each row containing a term_id
, meta_key
(value of order) and meta_value
I use wp_get_object_terms()
on the front end of the site to only pull through terms which have products assigned to them. How can I order the terms based on the values stored in the above mentioned table?
WooCommerce hooks into the terms_clauses
filter to enable terms to be sorted by this with a call to get_terms()
but there doesn't appear to be anyway to filter the wp_get_object_terms()
database query.