当我去查看预定的帖子时,我希望默认的排序顺序是最快的预定帖子在顶部。
默认情况下,帖子确实是按帖子日期降序排列的,因此如果您希望顺序改为升序,则没有管理设置,但您可以使用pre_get_posts
hook 像这样:
add_action( \'pre_get_posts\', \'my_admin_pre_get_posts\' );
function my_admin_pre_get_posts( $query ) {
// Do nothing if the post_status parameter in the URL is not "future", or that
// a specific orderby (e.g. title) is set.
if ( ! isset( $_GET[\'post_status\'] ) || \'future\' !== $_GET[\'post_status\'] ||
! empty( $_GET[\'orderby\'] )
) {
return;
}
// Modify the query args if we\'re on the admin Posts page for managing posts
// in the default "post" type.
if ( is_admin() && $query->is_main_query() &&
\'edit-post\' === get_current_screen()->id
) {
$query->set( \'orderby\', \'date\' ); // default: date
$query->set( \'order\', \'ASC\' ); // default: DESC
}
}