WordPress返回文章元数据值函数:get_post_custom_values

WordPress函数get_post_custom_values返回文章所有元数据的值。

get_post_custom_values( string $key = '', int $post_id )

函数参数

$key

字符串

自定义字段的键

$post_id

整数

文章的ID

函数返回值

Array
(
    [0] => 123
)

函数使用示例

$mykey_values = get_post_custom_values( 'views' );
 
foreach ( $mykey_values as $key => $value ) {
    echo "$key => $value ( 'views' )<br />"; 
}

扩展阅读

get_post_custom_values()函数位于:wp-includes/post.php

相关函数:

阿里云