函数原型
get_post_types_by_support( array|string $feature, string $operator = ‘and’ ): string[]
函数描述
Retrieves a list of post type names that support a specific feature.
是否弃用
未弃用
函数参数
-
$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'and'.Default:
'and'
函数返回值
string[] A list of post type names.
函数位置
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 ) );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 4.5.0 | Introduced. |

