The post_type_supports() WordPress PHP function checks if a specific post type supports a given feature.
Usage
post_type_supports( $post_type, $feature );
Example:
if ( post_type_supports( 'post', 'comments' ) ) { // The 'post' post type supports comments. }
Parameters
$post_type
(string) – The post type being checked.$feature
(string) – The feature being checked.
More information
See WordPress Developer Resources: post_type_supports()
Examples
Check if posts support comments
This example checks if the ‘post’ post type supports comments.
if ( post_type_supports( 'post', 'comments' ) ) { // The 'post' post type supports comments. }
Check if pages support excerpts
This example checks if the ‘page’ post type supports excerpts.
if ( post_type_supports( 'page', 'excerpt' ) ) { // The 'page' post type supports excerpts. }
Check if custom post type supports featured images
This example checks if a custom post type called ‘product’ supports featured images.
if ( post_type_supports( 'product', 'thumbnail' ) ) { // The 'product' post type supports featured images. }
Check if posts support custom fields
This example checks if the ‘post’ post type supports custom fields.
if ( post_type_supports( 'post', 'custom-fields' ) ) { // The 'post' post type supports custom fields. }
Check if posts support revisions
This example checks if the ‘post’ post type supports revisions.
if ( post_type_supports( 'post', 'revisions' ) ) { // The 'post' post type supports revisions. }