WordPress: Function Reference/get post custom keys:修订间差异
来自站长百科
无编辑摘要 |
无编辑摘要 |
||
第1行: | 第1行: | ||
==描述== | ==描述== | ||
返回一个数组,包含某篇文章或者网页的所有自定义fields。也看看[[WordPress:Function_Reference/get_post_custom|get_post_custom()]] 和[[WordPress:Function_Reference/get_post_custom_values|get_post_custom_values()]] | 返回一个数组,包含某篇文章或者网页的所有自定义fields。也看看[[WordPress:Function_Reference/get_post_custom|get_post_custom()]] 和[[WordPress:Function_Reference/get_post_custom_values|get_post_custom_values()]] | ||
==用法== | ==用法== | ||
%%% <?php get_post_custom_keys($post_id); ?> %%% | %%% <?php get_post_custom_keys($post_id); ?> %%% | ||
==例子== | ==例子== | ||
===默认用法=== | ===默认用法=== | ||
下面的例子会将一个变数(<tt>$custom_field_keys</tt>)设置为一个数组,包含当前文章的所有自定义fields的关键词,然后再输出。 | 下面的例子会将一个变数(<tt>$custom_field_keys</tt>)设置为一个数组,包含当前文章的所有自定义fields的关键词,然后再输出。 | ||
第45行: | 第28行: | ||
'''''注:'''不管一个关键字分配了多少参数值(自定义fields),关键字在数组中只显示一次。'' | |||
==参数== | ==参数== | ||
{{Parameter|$post_id|integer|The post ID whose custom field keys will be retrieved.|optional|当前文章t}} | {{Parameter|$post_id|integer|The post ID whose custom field keys will be retrieved.|optional|当前文章t}} | ||
==相关的== | ==相关的== | ||
[[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 values|get_post_custom_values()]] | [[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 values|get_post_custom_values()]] |
2008年7月23日 (三) 14:13的最新版本
描述[ ]
返回一个数组,包含某篇文章或者网页的所有自定义fields。也看看get_post_custom() 和get_post_custom_values()
用法[ ]
%%% <?php get_post_custom_keys($post_id); ?> %%%
例子[ ]
默认用法[ ]
下面的例子会将一个变数($custom_field_keys)设置为一个数组,包含当前文章的所有自定义fields的关键词,然后再输出。
<?php $custom_field_keys = get_post_custom_keys(); foreach ( $custom_field_keys as $key => $value ) echo $key . " => " . $value . "<br />"; ?>
If the post contains custom fields with the keys mykey and yourkey, the output would be:
0 => mykey
1 => yourkey
2 => _edit_last
3 => _edit_lock
4 => _wp_page_template
注:不管一个关键字分配了多少参数值(自定义fields),关键字在数组中只显示一次。
参数[ ]
相关的[ ]
add_post_meta(), delete_post_meta(), get_post_meta(), update_post_meta(), get_post_custom(), get_post_custom_values()