get_post_custom

函式
get_post_custom ( $post_id = 0 )
引數
  • (int) $post_id Optional. Post ID. Default is the ID of the global `$post`.
    Required:
返回值
  • (mixed) An array of values. False for an invalid `$post_id` (non-numeric, zero, or negative value). An empty string if a valid but non-existing post ID is passed.
定義位置
相關方法
get_post_custom_keyspost_customget_post_custom_valuesget_post_timeget_post_ancestors
引入
1.2.0
棄用
-

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

檢索文章的元欄位,基於文章的ID。

在可能的情況下,從快取中檢索文章的元欄位,因此該函式被優化為可多次呼叫。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_post_custom( $post_id = 0 ) {
$post_id = absint( $post_id );
if ( ! $post_id ) {
$post_id = get_the_ID();
}
return get_post_meta( $post_id );
}
function get_post_custom( $post_id = 0 ) { $post_id = absint( $post_id ); if ( ! $post_id ) { $post_id = get_the_ID(); } return get_post_meta( $post_id ); }
function get_post_custom( $post_id = 0 ) {
	$post_id = absint( $post_id );

	if ( ! $post_id ) {
		$post_id = get_the_ID();
	}

	return get_post_meta( $post_id );
}

常見問題

FAQs
檢視更多 >