To make the most of the Query Builder, we return a custom object instead of the usual WP_Post. This means we can add and modify it to suit.

The main thing the Post Model changes is that it removes the post_ prefix from the property names. For example $post->post_title becomes $post->title.

It also includes some methods to make working with posts a little more pleasant.

Available Methods

date

The date method allows you to format the post date property. By default, it’ll return the date like so: May 18, 2023

You can also pass a valid PHP date format, if you prefer:

$post->date( 'Y-m-d h:i' ); // 2024-05-18 12:00