get_post_custom_keys

函式
get_post_custom_keys ( $post_id = 0 )
引數
  • (int) $post_id Optional. Post ID. Default is the ID of the global `$post`.
    Required:
返回值
  • (array|void) Array of the keys, if retrieved.
定義位置
相關方法
get_post_customget_post_custom_valuesget_post_statesget_post_ancestorsget_post_time
引入
1.2.0
棄用
-

get_post_custom_keys函式用於檢索給定文章的自定義欄位的所有鍵的陣列。它只接受一個引數,即文章的ID。

檢索一個文章的元欄位名稱。

如果沒有元欄位,則不返回(null)。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_post_custom_keys( $post_id = 0 ) {
$custom = get_post_custom( $post_id );
if ( ! is_array( $custom ) ) {
return;
}
$keys = array_keys( $custom );
if ( $keys ) {
return $keys;
}
}
function get_post_custom_keys( $post_id = 0 ) { $custom = get_post_custom( $post_id ); if ( ! is_array( $custom ) ) { return; } $keys = array_keys( $custom ); if ( $keys ) { return $keys; } }
function get_post_custom_keys( $post_id = 0 ) {
	$custom = get_post_custom( $post_id );

	if ( ! is_array( $custom ) ) {
		return;
	}

	$keys = array_keys( $custom );
	if ( $keys ) {
		return $keys;
	}
}

常見問題

FAQs
檢視更多 >