New! TypeRocket v5 is now available. See docs.
Access all of Typerocket. Get Pro.
Removing the Editor from Post Types
( v4 )
The WordPress editor has gotten a lot better over the years. However, You don't always want to use it. A custom post type used for photo galleries doesn't need the editor; but how do you remove it? By using the remove_post_type_support() function.
Custom Post Type
Think about the gallery post type. All it needs are photos. To remove the editor:
- Open your themes
functions.phpfile. - Pass the post type ID as the first argument for
remove_post_type_support(). - Then, call the function during the
initaction and set the priority to 99.
<?php // functions.php
add_action( 'init', function() {
remove_post_type_support( 'gallery', 'editor' );
}, 99);
Note: Setting the priority to 99 will make sure it is called after your post type has been registered. You can always increase the number. 99999 might work better for you.
Posts and Pages
If you want to remove the editor from the post and page post types do can do the same.
add_action( 'init', function() {
remove_post_type_support( 'post', 'editor' );
remove_post_type_support( 'page', 'editor' );
}, 99);
Support Title Only
If you are registering a post type with TypeRocket and only want the main title field you can use the setArgument() method instead.
$gallery = tr_post_type('Gallery');
$gallery->setArgument('supports', ['title'] );
WordPress Supports List
WordPress has a list of features any post type can add or remove support for.
-
titlefor the main title field. -
editorfor the WordPress editor. -
authorfor the publishing author select box. -
thumbnailfor the featured image. -
excerptfor the excerpt meta box. -
trackbacksfor trackbacks if the content is linked to externally. -
custom-fieldsfor the WordPress built-in custom fields meta box. -
commentsfor comments. -
revisionsfor revisions of the post type. -
page-attributesfor template and menu order (hierarchical only). -
post-formatsfor post formats.
Found a typo? Something is wrong in this documentation? Fork and edit it!