There are times where you need to use $post within a theme or within a plugin. I went looking for the different options that I could use and for some reason didn't find a spot where it had all the information I needed so I figured it is something that I need to reference quite frequently so why not compile a list of properties and also what gets returned with a little explanation. So here it is. When using it lets say you need to get the title for usage, $post->post_title will allow you to echo or store in a string for manipulation.

Property Sample Value Notes
post_author 1 Post author’s user number
post_date 2008-03-15 19:22:29
post_date_gmt 2008-03-16 02:22:29 GMT = Greenwich Mean Time
post_content Actual post content, including markup
post_title Post title
post_category 0 Number representing post category ID#
post_excerpt Plain text without markup
post_status publish, pending, draft, private, inherit Current status of the post
comment_status open Possible values: open / closed
ping_status open open / closed
post_password Will be empty if no password
post_name statistics Same as post slug
to_ping,, List of urls to ping when post is published (for unpublished posts)
pinged,, List of urls that have been pinged (for published posts)
post_modified 2008-07-01 19:41:28 Date the post was last modified
post_modified_gmt 2008-07-02 02:41:28 GMT date post was last modified
post_content_filtered Exists to store a cached version of post content (most likely with all the the_content filters already applied). If you’ve got a plugin that runs a very resource heavy filter on content, you might consider caching the results with post_content_filtered, and calling that from the front end instead.
post_parent ID# of this post’s parent. In the case of attachments, will be the post it’s attached to. Defaults to 0 if no parent.
guid http://www.blogurl/postslug Global Unique Identifier. The “real” URL to the post, not the permalink version. For pages, this is the actual URL. In the case of files (attachments), this holds the URL to the file.
menu_order 0
Holds values for display order of pages. Only works with pages, not posts.
post_type page
Self-explanatory for pages and posts. Any files uploaded are attachments and post revisions saved as revision
post_mime_type text/html
Only used for files (attachments). Contains the MIME type of the uploaded file.
comment_count 4 Number of comments, pings, and trackbacks combined

Share This

We are using cookies on our website

Please confirm, if you accept our tracking cookies. You can also decline the tracking, so you can continue to visit our website without any data sent to third party services.