Title: post_custom
Published: April 25, 2014
Last modified: February 24, 2026

---

# post_custom( string $key ): array|string|false

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/post_custom/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/post_custom/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/post_custom/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/post_custom/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/post_custom/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/post_custom/?output_format=md#wp--skip-link--target)

Retrieves post custom meta data field.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/post_custom/?output_format=md#parameters)󠁿

 `$key`stringrequired

Meta data key name.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/post_custom/?output_format=md#return)󠁿

 array|string|false Array of values, or single value if only one element exists.

False if the key does not exist.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/post_custom/?output_format=md#source)󠁿

    ```php
    function post_custom( $key = '' ) {
    	$custom = get_post_custom();

    	if ( ! isset( $custom[ $key ] ) ) {
    		return false;
    	} elseif ( 1 === count( $custom[ $key ] ) ) {
    		return $custom[ $key ][0];
    	} else {
    		return $custom[ $key ];
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/post-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/post-template.php#L1106)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/post-template.php#L1106-L1116)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/post_custom/?output_format=md#related)󠁿

| Uses | Description | 
| [get_post_custom()](https://developer.wordpress.org/reference/functions/get_post_custom/)`wp-includes/post.php` |

Retrieves post meta fields, based on post ID.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/post_custom/?output_format=md#changelog)󠁿

| Version | Description | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fpost_custom%2F)
before being able to contribute a note or feedback.