编辑“WordPress:Function Reference/get post custom keys

跳转至: 导航、​ 搜索
警告:您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您登录创建一个账户,您的编辑将归属于您的用户名,且将享受其他好处。

该编辑可以被撤销。 请检查下面的对比以核实您想要撤销的内容,然后发布下面的更改以完成撤销。

最后版本 您的文本
第1行: 第1行:
== Description ==
==描述==
==描述==
Returns an array containing the keys of all custom fields of a particular post or page. See also [[WordPress:Function_Reference/get_post_custom|get_post_custom()]] and [[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()]]
返回一个数组,包含某篇文章或者网页的所有自定义fields。也看看[[WordPress:Function_Reference/get_post_custom|get_post_custom()]] 和[[WordPress:Function_Reference/get_post_custom_values|get_post_custom_values()]]
== Usage ==


==用法==
==用法==


%%% <?php get_post_custom_keys($post_id); ?> %%%
%%% <?php get_post_custom_keys($post_id); ?> %%%
%%% <?php get_post_custom_keys($post_id); ?> %%%
== Examples ==
=== Default Usage ===


==例子==
==例子==
===默认用法===
===默认用法===
The following example will set a variable (<tt>$custom_field_keys</tt>) as an array containing the keys of all custom fields in the current post, and then print it.
<pre><?php


下面的例子会将一个变数(<tt>$custom_field_keys</tt>)设置为一个数组,包含当前文章的所有自定义fields的关键词,然后再输出。
下面的例子会将一个变数(<tt>$custom_field_keys</tt>)设置为一个数组,包含当前文章的所有自定义fields的关键词,然后再输出。
第28行: 第45行:




  $custom_field_keys = get_post_custom_keys();
  foreach ( $custom_field_keys as $key => $value )
    echo $key . " => " . $value . "<br />";
?></pre>
如果文章包含关键字为 ''mykey'' and ''yourkey''的自定义field,输出就会是:
<div style="border:1px solid blue; width:50%; margin: 20px; padding:20px">
0 => mykey<br />
1 => yourkey<br />
2 => _edit_last<br />
3 => _edit_lock<br />
4 => _wp_page_template<br />
</div>
'''''Note:''' Regardless of how many values (custom fields) are assigned to one key, that key will only appear once in this array.''
'''''注:'''不管一个关键字分配了多少参数值(自定义fields),关键字在数组中只显示一次。''
'''''注:'''不管一个关键字分配了多少参数值(自定义fields),关键字在数组中只显示一次。''
== Parameters ==


==参数==


==参数==
{{Parameter|$post_id|integer|The post ID whose custom field keys will be retrieved.|optional|Current post}}


{{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}}


== 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 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()]]
[[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-mediawiki:版权的细节)。 未经许可,请勿提交受版权保护的作品!
取消 编辑帮助(在新窗口中打开)

本页使用的模板: