Skip to main content
fixed orderby. removed post status
Source Link
Joey Yax
  • 851
  • 5
  • 7

Why wouldn't you just pull them in the order you need instead of reversing the array?

$args = array(
  'post_type' => 'attachment',
  'posts_per_page' => -1, // correct key is posts_per_page, not numberposts
  'post_status' => null,
  'orderby' => 'post_date''date'
  'order' => 'ASC',
  'post_parent' => $post->ID
);

$attachments = get_posts( $args );

Why wouldn't you just pull them in the order you need instead of reversing the array?

$args = array(
  'post_type' => 'attachment',
  'posts_per_page' => -1, // correct key is posts_per_page, not numberposts
  'post_status' => null,
  'orderby' => 'post_date'
  'order' => 'ASC',
  'post_parent' => $post->ID
);

$attachments = get_posts( $args );

Why wouldn't you just pull them in the order you need instead of reversing the array?

$args = array(
  'post_type' => 'attachment',
  'posts_per_page' => -1, // correct key is posts_per_page, not numberposts
  'orderby' => 'date'
  'order' => 'ASC',
  'post_parent' => $post->ID
);

$attachments = get_posts( $args );
Source Link
Joey Yax
  • 851
  • 5
  • 7

Why wouldn't you just pull them in the order you need instead of reversing the array?

$args = array(
  'post_type' => 'attachment',
  'posts_per_page' => -1, // correct key is posts_per_page, not numberposts
  'post_status' => null,
  'orderby' => 'post_date'
  'order' => 'ASC',
  'post_parent' => $post->ID
);

$attachments = get_posts( $args );