WP_Post Object

WP_Post object summary

The WP_Post object is a class that is used to display post contents from the database. This object is created when the function get_post() is called. It holds the data from the wp_posts table in the database for the posts in the query.

WP_Post object data contained in the object

The WP_Post object holds all of the data that is stored for a post. This data includes things like the post title, excerpt, content, date, author, and comments. It also stores details about if a post is password protected or not, when it was last modified, and the status of the post. These are all variables that can be referenced to display the post information.

WP_Post object role in the page load

When a page loads with a get_post() function call, the WP_Post object brings back the data from that query. The get_post() function is stored in a variable that becomes the WP_Post object. This variable/object is then referenced to display the post data. The code for this might look like this:

$newpost = get_post();
$post_title = $newpost->post_title;

Depending on the page where it is being used and the arguments used, it can pull different posts from the database.

Summary of the Documentation

WP_Post is the object that holds all of the post data that is needed to display posts on a WordPress site. It holds a lot of data on posts which allow us to create a post layout that has as much (or as little) information as we wish to display about the post.

Sources