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查詢文章時。

獲取文章狀態的列表。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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
檢視更多 >