Title: WP terms doesn&#8217;t sort
Last modified: May 20, 2022

---

# WP terms doesn’t sort

 *  [manvydasj](https://wordpress.org/support/users/manvydasj/)
 * (@manvydasj)
 * [4 years ago](https://wordpress.org/support/topic/wp-terms-doesnt-sort/)
 * Hello,
 * I am trying to get sorted terms filtered by custom term meta.
 *     ```
           $parent_term_id = 60;
           $cat_args = array(
               'parent' => $parent_term_id,
               'orderby' => 'DATE',
               'order' => 'ASC',
               'meta_key' => 'created',
               'meta_type' => 'DATE'
           );
           $terms =  get_terms('product_cat', $cat_args);
       ```
   
 * I got these terms filtered and it returns only with ‘created’ meta value. However,
   if I print term meta values (‘created’), I got
 *     ```
       [“2021-12-20”][“2021-11-03”][“2022-05-03”][“2022-02-18”][“2021-11-26”][“2020-10-27”]
       ```
   
 * Which is not ordered by date. What is wrong in my query?

Viewing 1 replies (of 1 total)

 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [4 years ago](https://wordpress.org/support/topic/wp-terms-doesnt-sort/#post-15662489)
 * When you are telling the query how to order, there’s no value for ‘DATE’ to oder
   by. What you are trying to order by is a meta value, not a term value (terms 
   don’t have datesby default, so you can’t just order by date anyway).
 * Looking at the [proper arguments for that function](https://developer.wordpress.org/reference/classes/wp_term_query/__construct/),
   you want to order by ‘meta_value’:
 *     ```
       $cat_args = array(
           'parent' => $parent_term_id,
           'orderby' => 'meta_value', // May also be meta_value_num if the values are numeric
           'order' => 'ASC',
           'meta_key' => 'created',
           'meta_type' => 'DATE'
          );
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘WP terms doesn’t sort’ is closed to new replies.

## Tags

 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/wp-terms-doesnt-sort/#post-15662489)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
