最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

admin - Order All Pages table in administration

programmeradmin2浏览0评论

In administration, in the "All Pages" section, each time I add a new page the table is refreshed order by page Title. I reorder the table clicking on "Date" column to keep working on the last updated pages, but every refresh the order change again to Title.

I cannot find any plugin or way for Wordpress to remember the last order selected. Is there any way to achive this?

TL;DR I want Wordpress to remember the order of "All Pages" in the administration.

In administration, in the "All Pages" section, each time I add a new page the table is refreshed order by page Title. I reorder the table clicking on "Date" column to keep working on the last updated pages, but every refresh the order change again to Title.

I cannot find any plugin or way for Wordpress to remember the last order selected. Is there any way to achive this?

TL;DR I want Wordpress to remember the order of "All Pages" in the administration.

Share Improve this question asked Jun 1, 2020 at 21:47 Alex AngelicoAlex Angelico 1033 bronze badges 1
  • Check my answer bellow. – Sabbir Hasan Commented Jun 6, 2020 at 15:23
Add a comment  | 

1 Answer 1

Reset to default 1

There is no plugin for that. But you can achieve this by using filters. Add following code to you theme's functions.php file:

/**
 * Order Admin Page List by Date by Default
 */

add_filter('pre_get_posts', 'my_set_page_order_in_admin' );
function my_set_page_order_in_admin( $wp_query ) {
    global $pagenow;
    if ( is_admin() && $_GET['post_type'] == 'page' && 'edit.php' == $pagenow && !isset($_GET['orderby'])) {
        $wp_query->set( 'orderby', 'date' );
        $wp_query->set( 'order', 'desc' );
    }
}
发布评论

评论列表(0)

  1. 暂无评论