Class: WP_Post

Core class used to implement the WP_Post object.


Properties

Name Type(s) Default Value Summary
ID integer Post ID.
post_author string ID of post author.

A numeric string, for compatibility reasons.

post_date string The post's local publication time.
post_date_gmt string The post's GMT publication time.
post_content string The post's content.
post_title string The post's title.
post_excerpt string The post's excerpt.
post_status string The post's status.
comment_status string Whether comments are allowed.
ping_status string Whether pings are allowed.
post_password string The post's password in plain text.
post_name string The post's slug.
to_ping string URLs queued to be pinged.
pinged string URLs that have been pinged.
post_modified string The post's local modified time.
post_modified_gmt string The post's GMT modified time.
post_content_filtered string A utility DB field for post content.
post_parent integer ID of a post's parent post.
guid string The unique identifier for a post, not necessarily a URL, used as the feed GUID.
menu_order integer A field used for ordering posts.
post_type string The post's type, like post or page.
post_mime_type string An attachment's mime type.
comment_count string Cached comment count.

A numeric string, for compatibility reasons.

filter string Stores the post object's sanitization level.

Does not correspond to a DB field.

page_template string
ancestors array
post_category integer
tag_input string

Methods

WP_Post:: __construct( WP_Post | object $post )

Constructor. Since 3.5.0.

Arguments

Name Type(s) Default Value Description
$post WP_Post | object

Post object.


WP_Post:: __get( string $key )

Getter. Since 3.5.0.

Arguments

Name Type(s) Default Value Description
$key string

Key to get.

Returns

mixed


WP_Post:: __isset( string $key )

Isset-er. Since 3.5.0.

Arguments

Name Type(s) Default Value Description
$key string

Property to check if set.

Returns

boolean


WP_Post:: filter( string $filter )

{@Missing Summary} Since 3.5.0.

Arguments

Name Type(s) Default Value Description
$filter string

Filter.

Returns

self | array | boolean | object | WP_Post


WP_Post:: get_instance( integer $post_id )

Retrieve WP_Post instance. Since 3.5.0.

Arguments

Name Type(s) Default Value Description
$post_id integer

Post ID.

Returns

WP_Post | false

Post object, false otherwise.


WP_Post:: to_array( )

Convert object to array. Since 3.5.0.

Returns

array

Object as array.


WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.