检索支持特定功能的帖子类型名称列表。
原型
get_post_types_by_support( array|string $feature, string $operator = 'and' )
参数
$feature
(array|string)
(Required)
单一功能或帖子类型应支持的一系列功能。
$operator
(string)
(Optional)
要执行的逻辑操作。 ‘或’表示只需要匹配数组中的一个元素; ‘和’表示所有元素必须匹配; ‘not’表示没有元素匹配。
返回值
(array)
帖子类型名称列表。
源文件
路径:wp-includes/post.php
<?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 ) );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/get_post_types_by_support/