WordPress获取文章元数据键函数:get_post_custom_keys
WordPress函数get_post_custom_keys用于获取文章所有元数据的键。 get_post_…
WordPress函数get_post_custom_keys用于获取文章所有元数据的键。
get_post_custom_keys( int $post_id )
函数参数
$post_id
整数,默认值:当前文章ID
文章的ID
函数返回值
文章的自定义字段不同,返回的结果也有所不同:
Array
(
    [0] => _edit_last
    [1] => _thumbnail_id
    [2] => _edit_lock
    [3] => views
    [4] => _wp_page_template
    [5] => _encloseme
)函数使用示例
以下示例排除了系统自带的meta,也就是仅返回用户自定义字段:
$custom_field_keys = get_post_custom_keys();
foreach ( $custom_field_keys as $key => $value ) {
    $valuet = trim($value);
    if ( '_' == $valuet{0} )
        continue;
    echo $key . " => " . $value . "<br />";
}扩展阅读
get_post_custom_keys()函数位于:wp-includes/post.php
相关函数:
- get_post_custom()
 - get_post_custom_values()
 - the_meta()
 - get_post_meta()
 
类别:WordPress函数讲解、 
		本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!