post_type_supports() WordPress Function
The post_type_supports() function allows you to add support for specific features to a custom post type. This function accepts two arguments: the post type slug and the feature name. For example, if you want to add support for post thumbnails to a custom post type, you would use the following code: add_post_type_support( 'my_post_type', 'thumbnail' ); You can add support for multiple features by passing an array of feature names to the function. This function allows you to add support for specific features to a custom post type. This function accepts two arguments: the post type slug and the feature name. For example, if you want to add support for post thumbnails to a custom post type, you would use the following code: add_post_type_support( 'my_post_type', 'thumbnail' ); You can add support for multiple features by passing an array of feature names to the function.
post_type_supports( string $post_type, string $feature ) #
Check a post type’s support for a given feature.
Parameters
- $post_type
(string)(Required)The post type being checked.
- $feature
(string)(Required)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
File: wp-includes/post.php
function post_type_supports( $post_type, $feature ) { global $_wp_post_type_features; return ( isset( $_wp_post_type_features[ $post_type ][ $feature ] ) ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |