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

  • (string) field Post field name.
  • (int|WP_Post) post Optional. Post ID or post object. Defaults to global $post.
  • (string) context Optional. How to filter the field. Accepts 'raw', 'edit', 'db', or 'display'. Default 'display'.
  • (string) The value of the post field on success, empty string on failure.
Defined at:
Change Log:
  • 4: .


Retrieves data from a post field based on Post ID.Examples of the post field will be, 'post_type', 'post_status', 'post_content', etc and based off of the post object property or key names. The context values are based off of the taxonomy filter functions and supported values are found within those functions.

Related Functions

get_post_time, get_term_field, get_post_meta, get_post_type, get_post

Top Google Results

User discussions

wpseek mobile