get_post_custom_keys()通过id获取文章/页面所有的自定义字段(post meta)的键

目录

描述

译文

返回一个数组,数组中含有特定文章或页面的所有自定义字段的关键字。get_post_custom_keys() and get_post_custom_values() 。

原文

Returns an array containing the keys of all custom fields of a particular post or page. See also get_post_custom() and get_post_custom_values()

get_post_custom_keys() 描述

用法

 <?php get_post_custom_keys($post_id); ?> 

get_post_custom_keys() 用法

参数

$post_id

(integer) (可选) The post ID whose custom field keys will be retrieved.

默认值: Current post

get_post_custom_keys() 参数

示例

Default Usage

The following example will set a variable ($custom_field_keys) as an array containing the keys of all custom fields in the current post, and then print it. Note: the if test excludes values for WordPress internally maintained custom keys such as _edit_last and _edit_lock.

If the post contains custom fields with the keys mykey and yourkey, the output would be something like:

0 => mykey
1 => yourkey

Note: Regardless of how many values (custom fields) are assigned to one key, that key will only appear once in this array.

get_post_custom_keys() 示例

源文件

get_post_custom_keys() 函数的代码位于 wp-includes/post.php.

get_post_custom_keys() 源文件

相关