post_custom

函式
post_custom ( $key = '' )
引數
  • (string) $key Meta data key name.
    Required:
    Default: (empty)
返回值
  • (array|string|false) Array of values, or single value if only one element exists. False if the key does not exist.
定義位置
相關方法
get_post_customget_post_custom_keyspost_custom_meta_boxpost_classget_post_custom_values
引入
1.5.0
棄用
-

post_custom: 這個函式用來檢索具有指定ID的文章的自定義文章資料。

檢索文章的自定義後設資料欄位。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function post_custom( $key = '' ) {
$custom = get_post_custom();
if ( ! isset( $custom[ $key ] ) ) {
return false;
} elseif ( 1 === count( $custom[ $key ] ) ) {
return $custom[ $key ][0];
} else {
return $custom[ $key ];
}
}
function post_custom( $key = '' ) { $custom = get_post_custom(); if ( ! isset( $custom[ $key ] ) ) { return false; } elseif ( 1 === count( $custom[ $key ] ) ) { return $custom[ $key ][0]; } else { return $custom[ $key ]; } }
function post_custom( $key = '' ) {
	$custom = get_post_custom();

	if ( ! isset( $custom[ $key ] ) ) {
		return false;
	} elseif ( 1 === count( $custom[ $key ] ) ) {
		return $custom[ $key ][0];
	} else {
		return $custom[ $key ];
	}
}

常見問題

FAQs
檢視更多 >