get_post_stati()
get_post_stati( array|string $args = array(), string $o…
get_post_stati( array|string $args = array(), string $output = ‘names’, string $operator = ‘and’ )
获取post状态列表。
Get a list of post statuses.
获取post状态列表。
Get a list of post statuses.
目录锚点:#说明#参数#返回#源码
说明(Description)
另见函数 register_post_status()
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $args | (array | string) | 可选 | 要与全局$wp_post_statuses对象的属性进行比较的post status参数的数组或字符串。 |
| $output | (string) | 可选 | 要返回的输出类型,可以是“names”或“objects”。 |
| $operator | (string) | 可选 | 要执行的逻辑操作或者’表示数组中只有一个元素需要匹配;’和’表示所有元素都必须匹配。 |
返回(Return)
(array)post状态名称或对象的列表。
源码(Source)
/**
* Get a list of post statuses.
*
* @since 3.0.0
*
* @global array $wp_post_statuses List of post statuses.
*
* @see register_post_status()
*
* @param 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.
* @param string $output Optional. The type of output to return, either 'names' or 'objects'. Default 'names'.
* @param 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'.
* @return array A list of post status names or objects.
*/
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);
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 3.0.0 | wp-includes/post.php:1160 | 18 | 1 function |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!