Skip to content

Instantly share code, notes, and snippets.

@ben-caplan
Last active August 29, 2015 14:00
Show Gist options
  • Save ben-caplan/11226052 to your computer and use it in GitHub Desktop.
Save ben-caplan/11226052 to your computer and use it in GitHub Desktop.
$desiredOrder = array('post', 'cpt1', 'cpt2', 'etc');
function reorder( $a, $b ) {
global $posts;
$ap = array_search( $a->post_type, $desiredOrder );
$bp = array_search( $b->post_type, $desiredOrder );
return ( $ap < $bp ) ? -1 : 1;
}
usort( $wp_query->posts, "reorder" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment