get_post_stati()返回文章状态名称

目录

描述

Returns an array of post status names or objects.

get_post_stati() 描述

用法

<?php get_post_stati$args$output$operator ); ?>

get_post_stati() 用法

参数

See wp_filter_object_list() for specific arguments list.

$args

(array/string) (可选) Array of key => value pairs used to filter results

默认值: array()

$output

(string) (可选) Whether to output names or objects.

默认值: 'names'

$operator

(string) (可选) Whether to return statuses matching ALL ('and') or ANY ('or') arguments.

默认值: 'and'

get_post_stati() 参数

返回值

An array of post names or objects, depending on $output parameter.

Note: The return value is the $wp_post_statuses global passed through wp_filter_object_list() with parameters passed to the function.

get_post_stati() 返回值

历史

  • 添加于 版本: 3.0.0

get_post_stati() 历史

源文件

get_post_stati() 函数的代码位于 wp-includes/post.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * 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);
}

get_post_stati() 源文件

相关