Created
July 19, 2020 20:13
-
-
Save kadimi/e8d24ea214216a31d0a257d345e4c4e6 to your computer and use it in GitHub Desktop.
SportsPress - Sort players by title in event editing pages
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
<?php | |
// SportsPress - Sort players by title in event editing pages | |
add_action( 'admin_init', function() { | |
add_filter( 'pre_get_posts', function( $query ) { | |
if( | |
get_current_screen()->parent_file === 'edit.php?post_type=sp_player' | |
&& $query->get( 'post_type' ) === 'sp_player' | |
) { | |
$query->set( 'orderby', 'title' ); | |
$query->set( 'order', 'ASC' ); | |
} | |
return $query; | |
} ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment