Created
April 8, 2016 15:04
-
-
Save Jany-M/0f29b6d948a85bb00660f7cddb08e444 to your computer and use it in GitHub Desktop.
[WordPress] Order Page and Hierarchical Custom Post Types list by date
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 | |
// Change all pages and hierarchical custom post types to date order | |
function custom_page_order( $wp_query ) { | |
global $pagenow; | |
if (is_admin() && 'edit.php' == $pagenow && !isset($_GET['orderby'])) { | |
$wp_query->set( 'orderby', 'date' ); | |
$wp_query->set( 'order', 'DSC' ); | |
} | |
} | |
add_filter('pre_get_posts', 'custom_page_order' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment