WordPress: Function Reference/get post custom values:修订间差异
(新页面: == Description == Returns an array containing all the values of the custom fields with a particular key (<tt>$key</tt>) of a particular post (<tt>$post_id</tt>). Returns nothing if no su...) |
无编辑摘要 |
||
第1行: | 第1行: | ||
== Description == | == Description == | ||
==描述== | |||
Returns an array containing all the values of the custom fields with a particular key (<tt>$key</tt>) of a particular post (<tt>$post_id</tt>). Returns nothing if no such key exists, or none is entered. See also [[WordPress:Function_Reference/get_post_custom|get_post_custom()]] and [[WordPress:Function_Reference/get_post_custom_keys|get_post_custom_keys()]]. | Returns an array containing all the values of the custom fields with a particular key (<tt>$key</tt>) of a particular post (<tt>$post_id</tt>). Returns nothing if no such key exists, or none is entered. See also [[WordPress:Function_Reference/get_post_custom|get_post_custom()]] and [[WordPress:Function_Reference/get_post_custom_keys|get_post_custom_keys()]]. | ||
返回一个数组,包含某篇文章(<tt>$post_id</tt>)某关键字(<tt>$key</tt>)自定义fields的所有参数值。如果不存在这样的关键字,或者没有输入任何内容,不返回任何内容。也看看[[WordPress:Function_Reference/get_post_custom|get_post_custom()]] 和[[WordPress:Function_Reference/get_post_custom_keys|get_post_custom_keys()]]。 | |||
== Usage == | == Usage == | ||
==用法== | |||
%%% <?php get_post_custom_values($key, $post_id); ?> %%% | |||
%%% <?php get_post_custom_values($key, $post_id); ?> %%% | %%% <?php get_post_custom_values($key, $post_id); ?> %%% | ||
第10行: | 第18行: | ||
=== Default Usage === | === Default Usage === | ||
==例子== | |||
===默认用法=== | |||
The following example sets a variable (<tt>$mykey_values</tt>) as an array containing the values of the custom fields of the current post with the key ''my_key''. | The following example sets a variable (<tt>$mykey_values</tt>) as an array containing the values of the custom fields of the current post with the key ''my_key''. | ||
<pre><?php | |||
下面的例子将一个变数(<tt>$mykey_values</tt>)设置为一个数组,包含关键字为''my_key''的当前文章的自定义fields的参数值。 | |||
<pre><?php | <pre><?php | ||
第25行: | 第40行: | ||
etc... | etc... | ||
</div> | </div> | ||
$mykey_values = get_post_custom_values('my_key'); | |||
foreach ( $mykey_values as $key => $value ) { | |||
echo $key . " => " . $value . "<br />"; | |||
} | |||
?></pre> | |||
<div style="border:1px solid blue; width:50%; margin: 20px; padding:20px"> | |||
0 => First value with "my_key" as its key<br /> | |||
1 => Second value with "my_key" as its key<br /> | |||
2 => Third value with "my_key" as its key<br /> | |||
etc... | |||
</div> | |||
== Parameters == | == Parameters == | ||
==参数== | |||
{{Parameter|$key|string|The key whose values you want returned.|required}} | {{Parameter|$key|string|The key whose values you want returned.|required}} | ||
{{Parameter|$post_id|integer|The post ID whose custom fields will be retrieved.|optional|Current post}} | {{Parameter|$post_id|integer|The post ID whose custom fields will be retrieved.|optional|Current post}} | ||
{{Parameter|$key|string|The key whose values you want returned.|required}} | |||
{{Parameter|$post_id|integer|The post ID whose custom fields will be retrieved.|optional|当前文章}} | |||
== Related == | == Related == | ||
==相关的== | |||
[[WordPress:Function Reference/add post meta|add_post_meta()]], [[WordPress:Function Reference/delete post meta|delete_post_meta()]], [[WordPress:Function Reference/get post meta|get_post_meta()]], [[WordPress:Function Reference/update post meta|update_post_meta()]], [[WordPress:Function Reference/get post custom|get_post_custom()]], [[WordPress:Function Reference/get post custom keys|get_post_custom_keys()]] | |||
[[WordPress:Function Reference/add post meta|add_post_meta()]], [[WordPress:Function Reference/delete post meta|delete_post_meta()]], [[WordPress:Function Reference/get post meta|get_post_meta()]], [[WordPress:Function Reference/update post meta|update_post_meta()]], [[WordPress:Function Reference/get post custom|get_post_custom()]], [[WordPress:Function Reference/get post custom keys|get_post_custom_keys()]] | [[WordPress:Function Reference/add post meta|add_post_meta()]], [[WordPress:Function Reference/delete post meta|delete_post_meta()]], [[WordPress:Function Reference/get post meta|get_post_meta()]], [[WordPress:Function Reference/update post meta|update_post_meta()]], [[WordPress:Function Reference/get post custom|get_post_custom()]], [[WordPress:Function Reference/get post custom keys|get_post_custom_keys()]] |
2008年7月19日 (六) 11:36的版本
Description
描述
Returns an array containing all the values of the custom fields with a particular key ($key) of a particular post ($post_id). Returns nothing if no such key exists, or none is entered. See also get_post_custom() and get_post_custom_keys().
返回一个数组,包含某篇文章($post_id)某关键字($key)自定义fields的所有参数值。如果不存在这样的关键字,或者没有输入任何内容,不返回任何内容。也看看get_post_custom() 和get_post_custom_keys()。
Usage
用法
%%% <?php get_post_custom_values($key, $post_id); ?> %%%
%%% <?php get_post_custom_values($key, $post_id); ?> %%%
Examples
Default Usage
例子
默认用法
The following example sets a variable ($mykey_values) as an array containing the values of the custom fields of the current post with the key my_key.
<?php 下面的例子将一个变数(<tt>$mykey_values</tt>)设置为一个数组,包含关键字为''my_key''的当前文章的自定义fields的参数值。 <pre><?php $mykey_values = get_post_custom_values('my_key'); foreach ( $mykey_values as $key => $value ) { echo $key . " => " . $value . "<br />"; } ?>
0 => First value with "my_key" as its key
1 => Second value with "my_key" as its key
2 => Third value with "my_key" as its key
etc...
$mykey_values = get_post_custom_values('my_key'); foreach ( $mykey_values as $key => $value ) { echo $key . " => " . $value . "
"; }
?>
0 => First value with "my_key" as its key
1 => Second value with "my_key" as its key
2 => Third value with "my_key" as its key
etc...
Parameters
参数
Related
相关的
add_post_meta(), delete_post_meta(), get_post_meta(), update_post_meta(), get_post_custom(), get_post_custom_keys()
add_post_meta(), delete_post_meta(), get_post_meta(), update_post_meta(), get_post_custom(), get_post_custom_keys()