Skip to main content

I have a simple WP_Query to get a list of posts of co-author (taxonomy author) order by date, this is the query :

                $username = get_the_author_meta( 'login', $author_id );
                $args = array(
                  'post_type' => 'any',
                  'orderby' => 'date',
                  //'orderby' => 'post_date',
                  'order'   => 'DESC',
                  'tax_query' => array(
                    array(
                      'taxonomy' => 'author',
                      'field' => 'name',
                      'terms' => $username
                      )
                  )
                );
                $query = new WP_Query( $args );
$username = get_the_author_meta( 'login', $author_id );
$args = array(
  'post_type' => 'any',
  'orderby' => 'date',
  //'orderby' => 'post_date',
  'order'   => 'DESC',
  'tax_query' => array(
    array(
      'taxonomy' => 'author',
      'field' => 'name',
      'terms' => $username
      )
  )
);
$query = new WP_Query( $args );

The result is always a list of posts ordering by date ASC... I have already search solution over internet without success... Any idea ?

Thanks a lot

I have a simple WP_Query to get a list of posts of co-author (taxonomy author) order by date, this is the query :

                $username = get_the_author_meta( 'login', $author_id );
                $args = array(
                  'post_type' => 'any',
                  'orderby' => 'date',
                  //'orderby' => 'post_date',
                  'order'   => 'DESC',
                  'tax_query' => array(
                    array(
                      'taxonomy' => 'author',
                      'field' => 'name',
                      'terms' => $username
                      )
                  )
                );
                $query = new WP_Query( $args );

The result is always a list of posts ordering by date ASC... I have already search solution over internet without success... Any idea ?

Thanks a lot

I have a simple WP_Query to get a list of posts of co-author (taxonomy author) order by date, this is the query :

$username = get_the_author_meta( 'login', $author_id );
$args = array(
  'post_type' => 'any',
  'orderby' => 'date',
  //'orderby' => 'post_date',
  'order'   => 'DESC',
  'tax_query' => array(
    array(
      'taxonomy' => 'author',
      'field' => 'name',
      'terms' => $username
      )
  )
);
$query = new WP_Query( $args );

The result is always a list of posts ordering by date ASC... I have already search solution over internet without success... Any idea ?

Thanks a lot

Tweeted twitter.com/StackWordPress/status/1373424113990180865
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link
Orfeo
  • 103
  • 1
  • 1
  • 5

WP_Query orderby date not working

I have a simple WP_Query to get a list of posts of co-author (taxonomy author) order by date, this is the query :

                $username = get_the_author_meta( 'login', $author_id );
                $args = array(
                  'post_type' => 'any',
                  'orderby' => 'date',
                  //'orderby' => 'post_date',
                  'order'   => 'DESC',
                  'tax_query' => array(
                    array(
                      'taxonomy' => 'author',
                      'field' => 'name',
                      'terms' => $username
                      )
                  )
                );
                $query = new WP_Query( $args );

The result is always a list of posts ordering by date ASC... I have already search solution over internet without success... Any idea ?

Thanks a lot