Checks a post type’s support for a given feature.
Parameters
$post_type
stringrequired- The post type being checked.
$feature
stringrequired- The feature being checked.
Return
bool Whether the post type supports the given feature.More Information
The $feature variable in the function will accept the following string values:
- ‘title’
- ‘editor’ (content)
- ‘author’
- ‘thumbnail’ (featured image) (current theme must also support Post Thumbnails)
- ‘excerpt’
- ‘trackbacks’
- ‘custom-fields’ (see Custom_Fields, aka meta-data)
- ‘comments’ (also will see comment count balloon on edit screen)
- ‘revisions’ (will store revisions)
- ‘page-attributes’ (template and menu order) (hierarchical must be true)
- ‘post-formats’ (see Post_Formats)
Please note in the ‘thumbnail’ value you can also use ‘attachment:audio’ and ‘attachment:video’ .
If the value is not available it will return false.
You can send any string in this field and it will return false unless you are checking for an accepted value.
Source
function post_type_supports( $post_type, $feature ) {
global $_wp_post_type_features;
return ( isset( $_wp_post_type_features[ $post_type ][ $feature ] ) );
}
Related
Used by | Description |
---|---|
WP_REST_Attachments_Controller::handle_featured_media()wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php | Determines the featured media based on a request param. |
WP_Post_Type::get_autosave_rest_controller()wp-includes/class-wp-post-type.php | Gets the REST API autosave controller for this post type. |
WP_Post_Type::get_revisions_rest_controller()wp-includes/class-wp-post-type.php | Gets the REST API revisions controller for this post type. |
WP_REST_Global_Styles_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php | Prepares links for the request. |
WP_REST_Templates_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php | Prepares links for the request. |
WP_REST_Post_Search_Handler::prepare_item()wp-includes/rest-api/search/class-wp-rest-post-search-handler.php | Prepares the search result for a given post ID. |
use_block_editor_for_post_type()wp-includes/post.php | Returns whether a post type is compatible with the block editor. |
register_and_do_post_meta_boxes()wp-admin/includes/meta-boxes.php | Registers the default post meta boxes, and runs the |
WP_REST_Posts_Controller::get_available_actions()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Gets the link relations available for the post and current user. |
WP_REST_Posts_Controller::get_schema_links()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Retrieves Link Description Objects that should be added to the Schema for the posts collection. |
WP_REST_Users_Controller::get_items_permissions_check()wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php | Permissions check for getting all users. |
WP_REST_Posts_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Prepares links for the request. |
WP_REST_Posts_Controller::get_item_schema()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Retrieves the post’s schema, conforming to JSON Schema. |
WP_REST_Posts_Controller::get_collection_params()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Retrieves the query params for the posts collection. |
WP_REST_Posts_Controller::get_items()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Retrieves a collection of posts. |
WP_Post_Type::add_supports()wp-includes/class-wp-post-type.php | Sets the features support for the post type. |
get_default_comment_status()wp-includes/comment.php | Gets the default comment status for a post type. |
wp_generate_attachment_metadata()wp-admin/includes/image.php | Generates attachment meta data and create image sub-sizes for images. |
wp_delete_user()wp-admin/includes/user.php | Delete user and optionally reassign posts and links to another user. |
get_inline_data()wp-admin/includes/template.php | Adds hidden fields with the data for use in the inline editor for posts and pages. |
get_media_item()wp-admin/includes/media.php | Retrieves HTML form for modifying the image attachment. |
edit_post()wp-admin/includes/post.php | Updates an existing post with values provided in |
get_default_post_to_edit()wp-admin/includes/post.php | Returns default post information to use when populating the “Write Post” form. |
page_attributes_meta_box()wp-admin/includes/meta-boxes.php | Displays page attributes form fields. |
post_format_meta_box()wp-admin/includes/meta-boxes.php | Displays post format form elements. |
WP_Media_List_Table::get_columns()wp-admin/includes/class-wp-media-list-table.php | |
WP_Posts_List_Table::inline_edit()wp-admin/includes/class-wp-posts-list-table.php | Outputs the hidden row displayed when inline editing |
WP_Posts_List_Table::get_columns()wp-admin/includes/class-wp-posts-list-table.php | |
WP_Posts_List_Table::_display_rows()wp-admin/includes/class-wp-posts-list-table.php | |
get_post_class()wp-includes/post-template.php | Retrieves an array of the class names for the post container element. |
get_body_class()wp-includes/post-template.php | Retrieves an array of the class names for the body element. |
wp_insert_post()wp-includes/post.php | Inserts or update a post. |
wp_revisions_to_keep()wp-includes/revision.php | Determines how many revisions to retain for a given post. |
wp_save_post_revision()wp-includes/revision.php | Creates a revision for the current version of a post. |
get_post_format()wp-includes/post-formats.php | Retrieve the format slug for a post |
wp_xmlrpc_server::wp_getComments()wp-includes/class-wp-xmlrpc-server.php | Retrieves comments. |
register_meta()wp-includes/meta.php | Registers a meta key. |
_WP_Editors::editor_settings()wp-includes/class-wp-editor.php | |
wp_print_media_templates()wp-includes/media-template.php | Prints the templates used in the media manager. |
Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |
To dump all possible variable strings.
To check if posts support comments:
Or, if pages support excerpts:
accepted slugs:
'title'
'editor' (content)
'author'
'thumbnail' (featured image) (current theme must also support Post Thumbnails)
'excerpt'
'trackbacks'
'custom-fields' (see Custom_Fields, aka meta-data)
'comments' (also will see comment count balloon on edit screen)
'revisions' (will store revisions)
'page-attributes' (template and menu order) (hierarchical must be true)
'post-formats' (see Post_Formats)