get_post_stati

函数
get_post_stati ( $args = array(), $output = 'names', $operator = 'and' )
参数
  • (array|string) $args Optional. Array or string of post status arguments to compare against properties of the global `$wp_post_statuses objects`. Default empty array.
    Required:
    Default: array()
  • (string) $output Optional. The type of output to return, either 'names' or 'objects'. Default 'names'.
    Required:
    Default: 'names'
  • (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. Default 'and'.
    Required:
    Default: 'and'
返回值
  • (string[]|stdClass[]) A list of post status names or objects.
相关
  • register_post_status()
定义位置
相关方法
get_post_statesget_post_statusget_post_statusesget_post_metaget_post_time
引入
3.0.0
弃用
-

get_post_stati: 这个函数检索一个所有可用的文章状态的数组。它可以用来按状态过滤文章,例如在使用WP_Query查询文章时。

获取文章状态的列表。

function get_post_stati( $args = array(), $output = 'names', $operator = 'and' ) {
	global $wp_post_statuses;

	$field = ( 'names' === $output ) ? 'name' : false;

	return wp_filter_object_list( $wp_post_statuses, $args, $operator, $field );
}

常见问题

FAQs
查看更多 >