get_post_custom_keys

函数


get_post_custom_keys ( $post_id = 0 )
参数
  • (int)
    $post_id
    Optional. Post ID. Default is the ID of the global `$post`.
    Required:
返回值
  • (array|void) Array of the keys, if retrieved.
定义位置
  • wp-includes/post.php
    , line 2604
引入
1.2.0
弃用

检索一个文章的元字段名称。

如果没有元字段,则不返回(null)。

function get_post_custom_keys( $post_id = 0 ) {
	$custom = get_post_custom( $post_id );

	if ( ! is_array( $custom ) ) {
		return;
	}

	$keys = array_keys( $custom );
	if ( $keys ) {
		return $keys;
	}
}