A
A
Alexander Sinitsyn2016-01-06 22:08:49
WordPress
Alexander Sinitsyn, 2016-01-06 22:08:49

How to order taxonomy terms by ACF field?

I do it like this:

get_terms('offertypes', array(
  'meta_key' => 'sort-field',
  'meta_type' => 'NUMERIC',
  'orderby' => 'meta_value_num',
  'order' => 'ASC'
));

If there is an option without ACF, then it will also work, as long as you print them in the right order :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2016-01-06
@a_u_sinitsin

No way, except to loop through the resulting array, getting a custom field for all elements and forming a new array. Which is actually not an option. So far, ACF does not store data in term_meta, but according to its own scheme. If the question is only about sorting, use the plugin https://wordpress.org/plugins/wp-term-order/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question