get_post_types_by_support

函数
get_post_types_by_support ( $feature, $operator = 'and' )
参数
  • (array|string) $feature Single feature or an array of features the post types should support.
    Required:
  • (string) $operator 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'.
    Required:
    Default: 'and'
返回值
  • (string[]) A list of post type names.
定义位置
相关方法
get_all_post_type_supportspost_type_supportsremove_post_type_supportadd_post_type_supportget_post_types
引入
4.5.0
弃用
-

get_post_types_by_support函数是一个WordPress函数,它检索一个支持指定功能的文章类型名称数组: 这个函数将特征名称作为参数,并返回一个文章类型名称的数组。

检索一个支持特定功能的文章类型名称列表。

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 ) );
}

常见问题

FAQs
查看更多 >