get_post_types_by_support() WordPress Function

The get_post_types_by_support() function allows you to retrieve a list of post types that support a certain feature. For example, you can use this function to get a list of post types that support thumbnails.

get_post_types_by_support( array|string $feature, string $operator = 'and' ) #

Retrieves a list of post type names that support a specific feature.


Parameters

$feature

(array|string)(Required)Single feature or an array of features the post types should support.

$operator

(string)(Optional) The logical operation to perform. 'or' means only one element from the array needs to match; 'and' means all elements must match; 'not' means no elements may match.

Default value: 'and'


Top ↑

Return

(string[]) A list of post type names.


Top ↑

Source

File: wp-includes/post.php

function get_post_types_by_support( $feature, $operator = 'and' ) {
	global $_wp_post_type_features;

	$features = array_fill_keys( (array) $feature, true );

	return array_keys( wp_filter_object_list( $_wp_post_type_features, $features, $operator ) );
}


Top ↑

Changelog

Changelog
VersionDescription
4.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More