The WP_Post object is a class that contains post information stored in the site's database. It retrieves the information from the relevant table and presents it as data about each post, which can be retrieved via various functions.
WP_Post Object Data
There are many pieces of metadata stored in the WP_Post object, some of which include:
- ID - The post's ID
- post_author - The post author's ID
- post_date - The time of the post's publication (based on local time zone)
- post_content, $post_title, $post_excerpt - The content, title, and excerpt of the post
- comment_status - Whether or not comments are allowed on the post
Other data content includes post modification time, unique identifier, type of post, and comment count.
WP_Post Page Load Role
When using a function like get_post() or get_the_excerpt(), the relevant row is retrieved from the wp_posts table. All data from the row is stored in a WP_Post object, which can be stored in variables by using functions to retrieve each piece of data.
Summary
The WP_Post object is a class that represents the core data of a single post, such as post ID, post author, post title, etc. The WP_Post object is created when functions like get_post are called, allowing you to retrieve the post data to store in a variable or echo as desired on the page.