It’s not clear what you’re looking for here, but you could try to use the posts_where
filter:
/**
* Remove posts, with a given status, on the edit.php (post) screen,
* when there's no post status filter selected.
*/
add_action( 'posts_where', function( $where, $q )
{
if( is_admin()
&& $q->is_main_query()
&& ! filter_input( INPUT_GET, 'post_status' )
&& ( $screen = get_current_screen() ) instanceof \WP_Screen
&& 'edit-post' === $screen->id
)
{
global $wpdb;
$status_to_exclude="project_close"; // Modify this to your needs!
$where .= sprintf(
" AND {$wpdb->posts}.post_status NOT IN ( '%s' ) ",
$status_to_exclude
);
}
return $where;
}, 10, 2 );
where you have to modify the $status_to_exclude
status. Here we target the edit.php
screen for the post
post type. We make sure the post_status
GET filter is not set.
So when you click on the All Posts admin menu link in the backend, this filtering is activated.
Hopefully you can adjust this further to your needs.