Order get_terms by term meta

get_terms supports a meta_query which calls a new WP_Meta_Query parameter as you can see here. To query your terms with your desired meta, you could change your function call to something like this:

$args = array(
  'taxonomy' => 'categoria-de-productos',
  'orderby' => 'meta_value_num',
  'order' => 'ASC',
  'hide_empty' => false,
  'hierarchical' => false,
  'parent' => 0,
  'meta_query' => [[
    'key' => 'wm-cat-prod-order',
    'type' => 'NUMERIC',
  ]],
);

$terms = get_terms( $args );

This code is untested and may needs to be changed in your example. But the links should guide you to the solution.

Leave a Comment