Skip to content

Instantly share code, notes, and snippets.

@sarvar
Created December 25, 2015 21:51
Show Gist options
  • Save sarvar/9f7c24ff390dcd5fd603 to your computer and use it in GitHub Desktop.
Save sarvar/9f7c24ff390dcd5fd603 to your computer and use it in GitHub Desktop.
Sort Posts (or Pages) by title
<?php
/*
Plugin Name: Set Post Order In Admin
Version: 0.1
Plugin URI: http://wordpress.org/support/topic/336715/
Description: In Posts->Edit, display posts in title order.
Author: MichaelH
Author URI: http://codex.wordpress.org/User:MichaelH/MyPlugins
*/
function set_post_order_in_admin( $wp_query ) {
if ( is_admin() ) {
$wp_query->set( 'orderby', 'title' );
$wp_query->set( 'order', 'ASC' );
}
}
add_filter('pre_get_posts', 'set_post_order_in_admin' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment