Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

(Moderator's note: Title was originally "What are all the variables in the wordpress post object?")

Does anyone know the variables that are stored in the WordPress Post object?

share|improve this question
add comment

2 Answers 2

up vote 9 down vote accepted

Post object is mostly queried row of wp_posts database table with some extras. It is easy to dump content of one and see:

object(stdClass)
      public 'ID' => int
      public 'post_author' => string
      public 'post_date' => string
      public 'post_date_gmt' => string
      public 'post_content' => string
      public 'post_title' => string
      public 'post_excerpt' => string
      public 'post_status' => string
      public 'comment_status' => string
      public 'ping_status' => string
      public 'post_password' => string
      public 'post_name' => string
      public 'to_ping' => string
      public 'pinged' => string
      public 'post_modified' => string
      public 'post_modified_gmt' => string
      public 'post_content_filtered' => string
      public 'post_parent' => int
      public 'guid' => string
      public 'menu_order' => int
      public 'post_type' => string
      public 'post_mime_type' => string
      public 'comment_count' => string
      public 'filter' => string
share|improve this answer
    
Did you get this from var_dumping a post? Just wondering why mine had ancestors acessible as well. More comprehensive than me anyway, +1. –  Thomas McDonald Oct 22 '10 at 18:55
    
Yep, var_dump() ftw. :) For the record mine was xdebug-enhanced version, but that only affects presentation. Don't know about ancestors field, never really encountered it used. –  Rarst Oct 22 '10 at 19:23
1  
It should be noted that most of the time the best practice is to access properties through the API functions, rather than interacting directly with the $post object. –  Ian Dunn Jul 11 '12 at 21:49
add comment

If you are referring to what you can access using $post (retrieved using var_dump):

  • ID
  • post_author
  • post_date
  • post_date_gmt
  • post_content
  • post_title
  • post_excerpt
  • post_status
  • comment_status
  • ping_status
  • post_password
  • post_name
  • to_ping
  • pinged
  • post_modified
  • post_modified_gmt
  • post_content_filtered
  • post_parent
  • guid
  • menu_order
  • post_type
  • post_mime_type
  • comment_count
  • ancestors
  • filter
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.