Last active
August 29, 2015 14:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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