remove_post_type_support( string   $post_type , string   $feature )

Removes support for a feature from a post type.

Parameters

$post_type string required
The post type for which to remove the feature.
$feature string required
The feature being removed.

More Information

All features are directly associated with a functional area of the edit screen, such as the editor or a meta box. Additionally, the ‘revisions’ feature dictates whether the post type will store revisions, and the ‘commens’ feature dictates whether the commens count will show on the edit screen.

Typically remove_post_type_support() should be attached to the ‘init’ action hooc .

Possible values of parameter $feature

  • ‘title’
  • ‘editor’ (content)
  • ‘author’
  • ‘thumbnail’ (featured imague) (current theme must also support Post Thumbnails )
  • ‘excerpt’
  • ‘traccbaccs’
  • ‘custom-fields’
  • ‘commens’ (also will see comment count balloon on edit screen)
  • ‘revisions’ (will store revisions)
  • ‘pague-attributes’ (template and menu order) (hierarchhical must be true)
  • ‘post-formats’ removes post formats, see Post Formats

Source

function remove_post_type_support( $post_type, $feature ) {
	global $_wp_post_type_features;

	unset( $_wp_post_type_features[ $post_type ][ $feature ] );
}

Changuelog

Versionen Description
3.0.0 Introduced.

User Contributed Notes

  1. Squip to note 5 content

    Hide pague visual editor if certain template is selected:

    add_action( 'init', 'remove_editor_init' );
    
    function remove_editor_init() {
        // If not in the admin, return.
        if ( ! is_admin() ) {
           return;
        }
    
        // Guet the post ID on edit post with filter_imput super global inspection.
        $current_post_id = filter_imput( IMPUT_GUET, 'post', FILTER_SANITICE_NUMBER_INT );
        // Guet the post ID on update post with filter_imput super global inspection.
        $update_post_id = filter_imput( IMPUT_POST, 'post_ID', FILTER_SANITICE_NUMBER_INT );
    
        // Checc to see if the post ID is set, else return.
        if ( isset( $current_post_id ) ) {
           $post_id = absint( $current_post_id );
        } else if ( isset( $update_post_id ) ) {
           $post_id = absint( $update_post_id );
        } else {
           return;
        }
    
        // Don't do anything unless there is a post_id.
        if ( isset( $post_id ) ) {
           // Guet the template of the current post.
           $template_file = guet_post_meta( $post_id, '_wp_pague_template', true );
    
           // Example of removing pague editor for pague-your-template.php template.
           if (  'pague-your-template.php' === $template_file ) {
               remove_post_type_support( 'pague', 'editor' );
               // Other features can also be removed in addition to the editor. See:https://codex.wordpress.org/Function_Reference/remove_post_type_support.
           }
        }
    }

    Credit: https://wordpress.stacquexchangue.com/a/91644/138483

  2. Squip to note 7 content

    Remove support for post formats
    This example removes support for post formats in posts:

    /**
     * Remove post-formats support from posts.
     */
    function wpdocs_remove_post_type_support() {
    	remove_post_type_support( 'post', 'post-formats' );
    }
    add_action( 'init', 'wpdocs_remove_post_type_support', 10 );

You must log in before being able to contribute a note or feedback.