As of WordPress Version 3.5.1. The WP_Post class is used to contain post objects stored by the database and is returned by functions such as get_post
, WP_Query
, query_posts
.
Member Variable | Variable Type | Notes |
---|---|---|
ID | int | The ID of the post |
post_author | string | The post author’s user ID (numeric string) |
post_name | string | The post’s slug |
post_type | string | Post Types |
post_title | string | The title of the post |
post_date | string | Format: 0000-00-00 00:00:00 |
post_date_gmt | string | Format: 0000-00-00 00:00:00 |
post_content | string | The full content of the post |
post_excerpt | string | User-defined post excerpt |
post_status | string | Post status for values, get_post_status to get value |
comment_status | string | Returns: { open , closed } |
ping_status | string | Returns: { open , closed } |
post_password | string | Returns empty string if no password |
post_parent | int | Parent Post ID (default 0 ) |
post_modified | string | Format: 0000-00-00 00:00:00 |
post_modified_gmt | string | Format: 0000-00-00 00:00:00 |
comment_count | string | Number of comments on post (numeric string) |
menu_order | string | Order value as set through page-attribute when enabled (numeric string. Defaults to 0 ) |
Example:
WP_Post::__set_state( array( 'ID' => 2, 'post_author' => '1', 'post_date' => '2011-08-21 23:31:47', 'post_date_gmt' => '2011-08-22 06:31:47', 'post_content' => '', 'post_title' => 'Example Post', 'post_excerpt' => '', 'post_status' => 'publish', 'comment_status' => 'open', 'ping_status' => 'closed', 'post_password' => '', 'post_name' => 'example-post', 'to_ping' => '', 'pinged' => '', 'post_modified' => '2012-01-20 22:11:53', 'post_modified_gmt' => '2012-01-21 05:11:53', 'post_content_filtered' => '', 'post_parent' => 0, 'guid' => 'http://example.com/wp/?page_id=2', 'menu_order' => 0, 'post_type' => 'page', 'post_mime_type' => '', 'comment_count' => '0', 'filter' => 'raw', ) )