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 [[WordPress:Function Reference/update post meta|update_post_...)
 
无编辑摘要
第1行: 第1行:
==Description==
==Description==
==描述==
This function returns the values of the custom fields with the specified key from the specified post. See also [[WordPress:Function Reference/update post meta|update_post_meta()]], [[WordPress:Function Reference/delete post meta|delete_post_meta()]] and [[WordPress:Function Reference/add post meta|add_post_meta()]].  
This function returns the values of the custom fields with the specified key from the specified post. See also [[WordPress:Function Reference/update post meta|update_post_meta()]], [[WordPress:Function Reference/delete post meta|delete_post_meta()]] and [[WordPress:Function Reference/add post meta|add_post_meta()]].  
这个函数返回了自定义区的参数值,带有某篇文章的特别的key。也看看[[WordPress:Function Reference/update post meta|update_post_meta()]], [[WordPress:Function Reference/delete post meta|delete_post_meta()]] 和 [[WordPress:Function Reference/add post meta|add_post_meta()]]。
==Usage==
==Usage==
==用法==
%%% <?php $meta_values = get_post_meta($post_id, $key, $single); ?> %%%
%%% <?php $meta_values = get_post_meta($post_id, $key, $single); ?> %%%
%%% <?php $meta_values = get_post_meta($post_id, $key, $single); ?> %%%
==Examples==
==Examples==
===Default Usage===
===Default Usage===
==例子==
===默认用法===
  <?php $key_1_values = get_post_meta(76, 'key_1'); ?>
  <?php $key_1_values = get_post_meta(76, 'key_1'); ?>
<?php $key_1_values = get_post_meta(76, 'key_1'); ?>
===Other Example===
===Other Example===
===其它的例子===
To retrieve only the first value of a given key:
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); ?>
<?php $key_1_value = get_post_meta(76, 'key_1', true); ?>


For a more detailed example, go to the [[WordPress:Function Reference/post meta Function Examples|post_meta Functions Examples]] page.
For a more detailed example, go to the [[WordPress:Function Reference/post meta Function Examples|post_meta Functions Examples]] page.
更详细的例子,请进入[[WordPress:Function Reference/post meta Function Examples|post_meta 函数例子]]网页。


==Parameters==
==Parameters==
==参数==
{{Parameter|$post_id|integer|The ID of the post from which you want the data.}}
{{Parameter|$post_id|integer|The ID of the post from which you want the data.}}
{{Parameter|$key|string|The key of the field you want.}}
{{Parameter|$key|string|The key of the field you want.}}
{{Parameter|$single|boolean|Whether you want the function to return the first value of the specified key (''true''), or an array containing all values of the specified key (''false'')|optional|false}}
{{Parameter|$single|boolean|Whether you want the function to return the first value of the specified key (''true''), or an array containing all values of the specified key (''false'')|optional|false}}
{{Parameter|$post_id|integer|你想要从中得到数据的文章的ID。}}
{{Parameter|$key|string|你想要的区的key。}}
{{Parameter|$single|boolean|你想要函数返回某个key的第一个参数值(''正确的''),或者一个数组包含了某个key的所有参数值 (''false'')|optional|false}}


==Return==
==Return==
==返回==
* If <tt>$single</tt> is set to <tt>false</tt>, or left blank, the function returns an array containing all values of the specified key.
* If <tt>$single</tt> is set to <tt>false</tt>, or left blank, the function returns an array containing all values of the specified key.
*如果<tt>$single</tt>设置为<tt>false</tt>,或者是空白的,函数返回一个数组,包含了某个key的所有参数值。
* If <tt>$single</tt> is set to <tt>true</tt>, the function returns the first value of the specified key (not in an array)
* If <tt>$single</tt> is set to <tt>true</tt>, the function returns the first value of the specified key (not in an array)
*如果<tt>$single</tt> 设置为<tt>true</tt>,函数返回某个key的第一个参数值(不在一个数组中)


==Related==
==Related==
==相关的==
[[WordPress:Function Reference/update post meta|update_post_meta()]], [[WordPress:Function Reference/delete post meta|delete_post_meta()]], [[WordPress:Function Reference/add post meta|add_post_meta()]], [[WordPress:Function Reference/get post custom|get_post_custom()]], [[WordPress:Function Reference/get post custom values|get_post_custom_values()]], [[WordPress:Function Reference/get post custom keys|get_post_custom_keys()]]
[[WordPress:Function Reference/update post meta|update_post_meta()]], [[WordPress:Function Reference/delete post meta|delete_post_meta()]], [[WordPress:Function Reference/add post meta|add_post_meta()]], [[WordPress:Function Reference/get post custom|get_post_custom()]], [[WordPress:Function Reference/get post custom values|get_post_custom_values()]], [[WordPress:Function Reference/get post custom keys|get_post_custom_keys()]]
[[WordPress:Function Reference/update post meta|update_post_meta()]], [[WordPress:Function Reference/delete post meta|delete_post_meta()]], [[WordPress:Function Reference/add post meta|add_post_meta()]], [[WordPress:Function Reference/get post custom|get_post_custom()]], [[WordPress:Function Reference/get post custom values|get_post_custom_values()]], [[WordPress:Function Reference/get post custom keys|get_post_custom_keys()]]

2008年7月19日 (六) 10:53的版本

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()