Make WordPress Core

Ticket #28439: 28439.patch

File 28439.patch, 1.0 KB (added by jchristopher, 10 years ago)

Add orderby argument of post_date to get_terms()

  • wp-includes/taxonomy.php

     
    13851385                $orderby = 't.slug';
    13861386        } else if ( 'term_group' == $_orderby ) {
    13871387                $orderby = 't.term_group';
     1388        } else if ( 'post_date' == $_orderby ) {
     1389                $orderby = 'p.post_date';
    13881390        } else if ( 'none' == $_orderby ) {
    13891391                $orderby = '';
    13901392        } elseif ( empty($_orderby) || 'id' == $_orderby ) {
     
    15611563
    15621564        $join = "INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id";
    15631565
     1566        // if we're ordering by date, we need to JOIN term_relationships and posts
     1567        if ( 'post_date' == $_orderby ) {
     1568                // JOIN with wp_term_relationships
     1569                $join .= " JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id";
     1570                // JOIN with wp_posts
     1571                $join .= " JOIN $wpdb->posts AS p ON p.ID = tr.object_id";
     1572        }
     1573
    15641574        $pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' );
    15651575
    15661576        /**