Created
July 25, 2011 11:03
-
-
Save kovshenin/1103915 to your computer and use it in GitHub Desktop.
Default posts order by name in admin
This file contains hidden or 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 | |
/* | |
* This snippet overrides the default post ordering in the edit posts table (admin), | |
* while keeping other post ordering options (by clicking on the table headings) | |
* still available. Useful for CMS-like setups and could be tweaked for | |
* custom post types as well | |
* | |
* Konstantin Kovshenin | |
* http://theme.fm | |
*/ | |
add_action( 'pre_get_posts', 'my_pre_get_posts', 10, 1 ); | |
function my_pre_get_posts( $query ) { | |
if ( $query->is_admin && ! isset( $query->query_vars['orderby'] ) ) { | |
$query->set('orderby', 'title'); | |
$query->set('order', 'asc'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment