Skip to content

Instantly share code, notes, and snippets.

@ibrokemywp
Last active August 29, 2015 14:09
Show Gist options
  • Save ibrokemywp/cdedf95c2c967cca4fec to your computer and use it in GitHub Desktop.
Save ibrokemywp/cdedf95c2c967cca4fec to your computer and use it in GitHub Desktop.
Don't sort your custom post type via pre_get_posts like this
/**
* Don't sort your custom post type admin lists this way because it will
* override other sorting being executed on this list.
*/
add_action( 'pre_get_posts', array( $this, 'admin_order_posts' ) );
public function admin_order_posts( $query ) {
if( ( is_admin() && $query->is_admin ) && $query->get( 'post_type' ) == 'my_custom_post_type' ) {
$query->set( 'orderby', 'menu_order' );
$query->set( 'order', 'ASC' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment