检索帖子自定义元数据字段。
原型
post_custom( string $key = '' )
参数
$key
(string)
(Optional)
元数据密钥名称。
返回值
(false|string|array)
值数组或单个值(如果只存在一个元素)。如果密钥不存在,则返回False。
源文件
路径:wp-includes/post-template.php
<?php
...
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];
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/post_custom/