Support » Plugins » Hacks » Order by post date with array_merge()?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Since get_pages returns an array of objects, you would have to use usort to sort the final merged array. Something along these lines:

    <?php usort( $pages, create_function('$a,$b', 'return strcmp($a->post_date, $b->post_date);') ); ?>

    Thank you for the help! That was just what I needed. As a note to anyone of my skill level with PHP who finds this and runs into the same problem I did, I was able to reverse the post order by changing ambrosite’s code to:

    <?php usort( $pages, create_function('$a,$b', 'return strcmp($b->post_date, $a->post_date);') ); ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Order by post date with array_merge()?’ is closed to new replies.