Trying to get the order of my custom query to display by Date created. Is this even possible with this query? Can you do a custom order? thanks for the help


$faq_cat_terms = get_terms( 'faq-cat' );

foreach ( $faq_cat_terms as $faq_cat ) {
    $faq_cat_query = new WP_Query( array(
        'orderby' => 'date',
        'post_type' => 'faq',
        'tax_query' => array(
                'taxonomy' => 'faq-cat',
                'field' => 'slug',
                'terms' => array( $faq_cat->slug ),
                'operator' => 'IN'
    ) );
  • this seems to be correct, isn't it working? Oct 23, 2015 at 17:35
  • 2
    you're ordering posts within each term by date created, but your question seems to be asking about ordering taxonomy terms. can you clarify exactly what you're trying to do? taxonomy terms don't have a creation date.
    – Milo
    Oct 23, 2015 at 18:17

1 Answer 1


Maybe you just need to add:

'order'   => 'DESC', //or ASC

depending on which order you want them to be.

The title of your question sounds like you are trying to order taxonomy terms by their creation date which is not possible, but you can work around it by using the ID.

For example:

 $terms = get_terms( 'YOUR_TAX_TERM', $args );

Since taxonomy term IDs are created incrementally if you sort by ID you are sorting them in the order that they were created:

$args = array(
    'orderby'    => 'ID', 
    'order'      => 'DESC',

While not technically ordering by the date, this will accomplish essentially the same thing.

  • I'm trying to do the same thing, but the answer doesn't work. Anyone? Aug 24, 2020 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.