add_post_type_support( string $post_type, string|array $feature )

Register support of certain features for a post type.


Description Description

All core features are directly associated with a functional area of the edit screen, such as the editor or a meta box. Features include: ‘title’, ‘editor’, ‘comments’, ‘revisions’, ‘trackbacks’, ‘author’, ‘excerpt’, ‘page-attributes’, ‘thumbnail’, ‘custom-fields’, and ‘post-formats’.

Additionally, the ‘revisions’ feature dictates whether the post type will store revisions, and the ‘comments’ feature dictates whether the comments count will show on the edit screen.


Parameters Parameters

$post_type

(string) (Required) The post type for which to add the feature.

$feature

(string|array) (Required) The feature being added, accepts an array of feature strings or a single string.


Top ↑

Source Source

File: wp-includes/post.php

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

	$features = (array) $feature;
	foreach ( $features as $feature ) {
		if ( func_num_args() == 2 ) {
			$_wp_post_type_features[ $post_type ][ $feature ] = true;
		} else {
			$_wp_post_type_features[ $post_type ][ $feature ] = array_slice( func_get_args(), 2 );
		}
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 2 content
    Contributed by Marc Heatley

    Unfortunately,

    add_post_type_support('page', 'thumbnail');

    won’t add featured images to pages. For that you need to [add theme support for post-thumbnails

    add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );

    https://developer.wordpress.org/reference/functions/add_theme_support/#post-thumbnails

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