WordPress:Function Reference/get post meta
Description
描述
This function returns the values of the custom fields with the specified key from the specified post. See also update_post_meta(), delete_post_meta() and add_post_meta().
这个函数返回了自定义区的参数值,带有某篇文章的特别的key。也看看update_post_meta(), delete_post_meta() 和 add_post_meta()。
Usage
用法
%%% <?php $meta_values = get_post_meta($post_id, $key, $single); ?> %%%
%%% <?php $meta_values = get_post_meta($post_id, $key, $single); ?> %%%
Examples
Default Usage
例子
默认用法
<?php $key_1_values = get_post_meta(76, 'key_1'); ?>
<?php $key_1_values = get_post_meta(76, 'key_1'); ?>
Other Example
其它的例子
To retrieve only the first value of a given key: 只返回所给key的第一个参数值:
<?php $key_1_value = get_post_meta(76, 'key_1', true); ?>
<?php $key_1_value = get_post_meta(76, 'key_1', true); ?>
For a more detailed example, go to the post_meta Functions Examples page.
更详细的例子,请进入post_meta 函数例子网页。
Parameters
参数
Return
返回
- If $single is set to false, or left blank, the function returns an array containing all values of the specified key.
- 如果$single设置为false,或者是空白的,函数返回一个数组,包含了某个key的所有参数值。
- If $single is set to true, the function returns the first value of the specified key (not in an array)
- 如果$single 设置为true,函数返回某个key的第一个参数值(不在一个数组中)
Related
相关的
update_post_meta(), delete_post_meta(), add_post_meta(), get_post_custom(), get_post_custom_values(), get_post_custom_keys()
update_post_meta(), delete_post_meta(), add_post_meta(), get_post_custom(), get_post_custom_values(), get_post_custom_keys()