How to Remove Post Via Email Settings in WordPress

Home » Snippets » How to Remove Post Via Email Settings in WordPress
0

Created with:

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

Are you looking to streamline your WordPress site by removing the post via email settings? These settings allow you to publish posts from an email account, but if you don’t use this feature and want to keep your dashboard cleaner, it can be beneficial to remove it. In this article, we’ll guide you on how to safely and effectively remove post via email settings from your WordPress website.

					function wpturbo_remove_post_via_email_settings() {
    remove_meta_box('postcustom', 'post', 'normal');
    remove_meta_box('trackbacksdiv', 'post', 'normal');
    remove_meta_box('commentstatusdiv', 'post', 'normal');
    remove_meta_box('commentsdiv', 'post', 'normal');
    remove_meta_box('slugdiv', 'post', 'normal');
    remove_meta_box('authordiv', 'post', 'normal');
}
add_action('admin_menu', 'wpturbo_remove_post_via_email_settings');
				

The code snippet starts off with the definition of the function wpturbo_remove_post_via_email_settings().

The purpose of this function is to remove multiple meta boxes from the post editing screen. WordPress uses a system of meta boxes to allow developers and users to add extra information and functionality to their posts.

Here is the list of meta boxes to be removed:

  • 'postcustom': This corresponds to the ‘Custom Fields’ box, which lets you add extra custom fields to your post.

  • 'trackbacksdiv': This corresponds to the ‘Send Trackbacks’ box, which allows you to manage the trackbacks for the current post.

  • 'commentstatusdiv': This corresponds to the ‘Discussion’ box, where you can toggle allowing comments and pings, i.e., notifications of new links to your post.

  • 'commentsdiv': This corresponds to the ‘Comments’ box, where the comments associated with the post are displayed.

  • 'slugdiv': This corresponds to the ‘Slug’ box, where you can define the URL slug for your post.

  • 'authordiv': This corresponds to the ‘Author’ box, which lets you change the post author.

Now, let’s see what each function does here.

remove_meta_box() is a WordPress function that hides meta boxes from the dashboard’s single post editing screen. The function accepts three strings as parameters:

  • $id – the ID of the meta box you want to remove
  • $page – the type of post to which the meta box belongs
  • $context – the area of the page in which the meta box is displayed

Lastly, the add_action('admin_menu', 'wpturbo_remove_post_via_email_settings') line hooks our custom function wpturbo_remove_post_via_email_settings() into the ‘admin_menu’ action. It tells WordPress to execute our function when it is setting the admin menu, ensuring the removal of the set meta boxes before the post editing screen is displayed.

Consider using remove_meta_box() judiciously. It can greatly diminish the ability to control various aspects of posts from the admin dashboard, perhaps making it harder for users to fully utilize WordPress’s functionalities. After using this function, the only way to restore these boxes would be by adding an equivalent add_meta_box() function to your code.

Register an account to save your snippets or go Pro to get more features.