How to remove scheduled posts from all posts in admin?

Question

How can I remove scheduled posts from all posts list in admin? I am always scheduling posts in the future and if they are many shown on all posts it is a mess to work with.

The URL for it is BOTH https://mywebsite.com/wp-admin/edit.php and https://mywebsite.com/wp-admin/edit.php?post_type=post&all_posts=1

First URL is when I click Posts in the main navigation menu and other URL is when I click All on horizontal menu (where we can specify if we want to see all, published, scheduled, draft posts…).

Even on second URL where WordPress adds all_posts=1 I couldn’t check for that value.

I can also see that checking for post_status always gives me "publish" no matter what post status URL I am on.

function ms_pre_get_posts_modify($query) {
    global $pagenow;
    
    // var_dump($query->get('all_posts')); nothing
    // var_dump($query->get('post_status')); I get "publish" on all types of post statuses, even on draft list? 
    // die();

    if (is_admin() && $query->is_main_query() && $pagenow === 'edit.php' && $query->get('all_posts') == 1) {
        $query->set('post_status', array('publish', 'draft'));
        return $query;
    }

}
add_action('pre_get_posts', 'ms_pre_get_posts_modify');
0
Marko 4 months 2020-12-20T06:10:20-05:00 0 Answers 9 views 0

Leave an answer

Browse
Browse