How To Disable Post Action in Dashboard Posts wordpress

How To Disable Post Action in Dashboard Posts wordpress
371 Views
0
(0)

By default, the dashboard displays options such as “All Posts,” “Published,” and “Trash” under the “Posts” section. While these options can be helpful for organizing and managing your content, there might be instances where you want to disable or remove them to simplify the dashboard or limit certain user permissions.

In this guide, we will explore different methods to disable or remove the “All Posts,” “Published,” and “Trash” options in the dashboard posts section of your WordPress website. Whether you are a website owner, developer, or administrator, this tutorial will provide you with step-by-step instructions on achieving a cleaner and more streamlined dashboard experience.

We will cover both manual methods, involving code modifications, and plugin-based solutions, which offer a simpler approach for users without coding expertise. It’s important to note that making changes to the code or using plugins may require caution and a backup of your WordPress site to ensure the integrity of your data.

So, let’s proceed and discover the methods that will help you disable or remove the “All Posts,” “Published,” and “Trash” options in the dashboard posts section of your WordPress website, empowering you to tailor the dashboard to your specific needs.

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

<?php
add_filter( 'views_edit-post', 'cxc_remove_all_view_post_call_back' );
function cxc_remove_all_view_post_call_back( $views ) {

	if( current_user_can( 'manage_options' ) ){

		$cxc_rm_views = [ 'all', 'publish', 'draft', 'pending', 'trash' ];

		if( $cxc_rm_views ){
			foreach( (array) $cxc_rm_views as $cxc_view ){
				if( isset( $views[$cxc_view] ) ){
					unset( $views[$cxc_view] );
				}
			}
		}
	}
	return $views;
} 
?>

Remove for custom post type “Exhibitions” in Dashboard

<?php
// You must change the filter named "view_edit-custom-post-type" if you have a custom post type.
add_filter( 'views_edit-exhibition', 'cxc_remove_all_view_exhibitions_call_back' );
function cxc_remove_all_view_exhibitions_call_back( $views ) {

	if( current_user_can( 'manage_options' ) ) {

		$cxc_rm_views = [ 'all', 'publish', 'draft', 'pending', 'trash' ];

		if( $cxc_rm_views ){
			foreach( (array) $cxc_rm_views as $cxc_view ){
				if( isset( $views[$cxc_view] ) ){
					unset( $views[$cxc_view] );
				}
			}
		}
	}
	return $views;
} 
?>

Conclusion

Disabling or removing the “All Posts,” “Published,” and “Trash” options in the dashboard posts section of your WordPress website can offer various benefits, such as simplifying the dashboard interface, enhancing user experience, and restricting certain user permissions.

We hope this guide has provided you with valuable insights and actionable steps to achieve your goal of disabling or removing the “All Posts,” “Published,” and “Trash” options in the dashboard posts section of your WordPress website. Best of luck with customizing your dashboard and optimizing your WordPress experience!

FAQs

Can I disable or remove the “All Posts,” “Published,” and “Trash” options without coding knowledge?

Yes, there are plugin-based solutions available that allow you to disable or remove these options without any coding knowledge.

Will disabling or removing these options affect the functionality of my website?

No, disabling or removing the “All Posts,” “Published,” and “Trash” options will not impact the functionality of your website. These options are primarily for managing and organizing posts within the dashboard and do not affect how your website is displayed to visitors.

Is it recommended to backup my WordPress site before making these changes?

Yes, it is highly recommended to create a backup of your WordPress site before making any modifications, especially when dealing with code or using plugins.

Can I customize other dashboard options besides the “All Posts,” “Published,” and “Trash” options?

Yes, both manual code modifications and plugins allow you to customize various other dashboard options.

How useful was this blog?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this blog.

By Hiren Ghoghari

My name is Hiren Ghoghri and I am from Gujarat. I started blogging in 2020. I am very passionate about writing or telling someone about WordPress Development, Elementor, Themes, Plugins, Advanced PHP and Web Development. Now I am ready to tell you every information related to Full Stack Web Development with the help of Codexcoach.com. Thank you

Leave a comment

Your email address will not be published. Required fields are marked *