WPDev.one
Core Function
View Source on Trac ↗

get_post_field()

get_post_field( mixed $field, mixed $post = null, mixed $context = 'display' )

Retrieves data from a post field based on Post ID.

Parameters 3 required

Name / Type Description
$field
string

Post field name.

Required
(int

| WP_Post) $post Optional. Post ID or post object. Defaults to global $post.

Required
string

$context Optional. How to filter the field. Accepts 'raw', 'edit', 'db', or 'display'. Default 'display'.

Required

Return Value

(string)
The value of the post field on success, empty string on failure.

Function Information

Since Version
2.3.0
Source File
wp-includes/post.php
Advertisement