Site icon Learn Web Development & Programming, Artificial Intelligence, WordPress, Shopify Articles

How To Disable (or Remove) “All Posts, Published, and Trash” in Dashboard Posts

How To Disable (or Remove) “All Posts, Published, and Trash” in Dashboard Posts

If you are looking for ways to completely remove the All, Published, and Trash in WordPress admin dashboard posts or custom post types. Then this article will provide you with complete steps to make it possible for you.

By default, WordPress displays all pages/posts in the admin area’s list, regardless of whether they are published or not. If you will refer to the below screenshot then you can see the count of All, Published, and trash.

Now, we want to remove the All and trash option from the above image place. Sometimes you will get more options in your dashboard like pending, draft.

The WP_Posts_List_Table class extends WP_List_Table and within the WP_List_Table::views() method we have the following dynamic views filter:

So we can use the generated views_edit-post filter to adjust the views of the post list table. I found this code to from here

Are you want to get implementation help, or modify or extend the functionality of this script?

A Tutorialswebsite Expert can do it for you.

Remove “All Posts, Published, and Trash” in Dashboard Posts

Let’s remove the allpublish, draft, pending, and trash for non-admins

You just simply copy and paste the following code to your theme functions.php file

In the above code, you can see the filter “view_edit-post” which only works for the post dashboard.

Remove “All Posts, Published, and Trash” for custom post type in Dashboard

If you have a custom post type then you need to modify the filter like “view_edit-custom-post-type”.

Also Read: How to display only published posts by default in the admin area?

For Example: Suppose I have a custom post type named recipe. then I will call the filter “view_edit-recipe”.

Note: the “all” and “mine” status links are hard-coded in the get_views() method of the WP_Posts_List_Table Class and aren’t filterable.

Are you want to get implementation help, or modify or extend the functionality of this script? submit your paid request

Conclusion

Well, In this article you will get the complete steps to Disable (or Remove) “All Posts, Published, and Trash” in Dashboard Posts. You can extend the functionality as per your requirement. I hope you found this tutorial helpful for your project. Keep learning!.

Exit mobile version