Removing Feature Support from any Post Type

In one of my post, I wrote on how to add Custom Post Type (CPT) and showed you how to add support for certain features. I recently came across another function that would allow you to remove certain features from any Post Type including the native "Post" type. This function was introduced with the release of WordPress 3.0.

In terms of Custom Post Type, you can easily remove the support for certain feature from the register_post_type function itself. However, it could be more useful in case if you want to remove certain support for the native "Post" type. Let's take a look at the sample function provided below.

function remove_comments_for_post() {
   remove_post_type_support('post','comments'); }
   add_action('admin_init','remove_comments_for_post' );

In this function all we are doing is to initialize a function (through add_action hook) when users are logged in and using the Administrative panel. This function would then call for the remove_post_type_support function with two different parameter, it's the name of the post type and the name of the support feature.

In my example, I removed the Comment support for the native "Post" type. Since, I am using Facebook comment system for my Blog and Article post, I don't need the support for comment. This is a very simple yet a very useful function, if you don't want certain features for certain post type.


Commenting is disabled.