How to Remove Support for Specific Post Type Features in WordPress

Home » Snippets » How to Remove Support for Specific Post Type Features 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

Whether you’re running a blog or a business website, chances are high that you’re using some type of post types in WordPress. While these are incredibly handy, there might be times when you want to remove support for specific post type features for various reasons – maybe to simplify your interface, streamline your operations, or because you’re not using certain features. Whatever your reasons, this article will guide you through the process of removing support for specific post type features in WordPress, helping you tailor your site more precisely to your needs.

					function wpturbo_remove_post_type_support() {
    remove_post_type_support( 'post', 'excerpt' );
}
add_action( 'init', 'wpturbo_remove_post_type_support' );
				

This code snippet consists of a function called wpturbo_remove_post_type_support() and an action hook init. The purpose of the code is to remove support for a certain feature(s) from a specific post type in WordPress.

The function wpturbo_remove_post_type_support() uses WordPress’s built-in function remove_post_type_support(), which accepts two parameters. The first parameter specifies the post type, and the second declares the feature to be removed.

In our case, we are removing the ‘excerpt’ feature from the ‘post’ post type.

remove_post_type_support( 'post', 'excerpt' );

The ‘excerpt’ support enables the excerpt input field in the dashboard. When this feature is removed, the excerpt input field is no longer available when you edit or create a ‘post’.

The add_action() function hooks our wpturbo_remove_post_type_support() function to run, when WordPress fires the ‘init’ action. The ‘init’ action hook fires after WordPress has finished loading but before any headers are sent. Hooking into ‘init’ is beneficial when you want to make modifications that aren’t dependent on other parts of WordPress that may yet have to load, such as the template hierarchy process.

add_action( 'init', 'wpturbo_remove_post_type_support' );

By executing this snippet of code, we effectively stop WordPress from supporting the excerpt meta box for posts on the WordPress dashboard.

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