Skip to content

Instantly share code, notes, and snippets.

@adamplabarge
Last active September 19, 2016 23:53
Show Gist options
  • Save adamplabarge/dd6c0f32d13adbdb8ddb890e314d77d1 to your computer and use it in GitHub Desktop.
Save adamplabarge/dd6c0f32d13adbdb8ddb890e314d77d1 to your computer and use it in GitHub Desktop.
<?php
$highlights = new WP_Query($args);
$sort = function(&$posts) {
$props = array('year', 'authors');
usort($posts, function($a, $b) use ($props) {
if ($a->$props[0] == $b->$props[0])
return $a->$props[1] > $b->$props[1] ? 1 : -1;
return $a->$props[0] < $b->$props[0] ? 1 : -1;
});
};
$sort($highlights->posts);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment