i have created custom post type
my problem is:
in admin column, posts are sorted by ID
how can change it to date. In other words, i want to sort post by recently
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityi have created custom post type
my problem is:
in admin column, posts are sorted by ID
how can change it to date. In other words, i want to sort post by recently
You must add this part to function.php:
add_action( 'pre_get_posts', 'example_func', 1 );
function example_func( $query ) {
if ( is_admin() && $query->is_main_query() ) {
$query->set( 'order' , 'DESC' );
}
return $query;
}
add_action( 'pre_get_posts', 'change_post_sort', 1 );
function change_post_sort( $query ) {
if ( is_admin() && $query->is_main_query() ) {
$query->set( 'order' , 'DESC' );
$query->set( 'orderby', 'modified');
return $query;
}