Removing Specific 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.

<?php
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.

Today In History

  •  
  •  

Comment

Leave a Reply

Note: Convet HTML, PHP, JavaScripts from Postable, before posting from comment section.
License: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution. Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.