Things

An object-oriented approach to WordPress queries and custom post types

Author:mitcho (Michael Yoshitaka Erlewine) (profile at wordpress.org)
WordPress version required:3.3
WordPress version tested:3.4.1
Plugin version:0.1
Added to WordPress repository:27-02-2012
Last updated:26-02-2012
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:0
Rated by:0
Plugin URI:
Total downloads:329
plugin download
Click to start download

An object-oriented approach to WordPress queries and custom post types. Un(der)documented beta.

So, here's the idea: anywhere where you need a loop, use get_things(), which will return an array-like collection of Things. get_things() will return Things from the main query; get_things($query_args) will run a new query for you. Each Thing in the collection is a magical object that will make your life better.

foreach ( get_things() as $thing ):
    // get an attribute (object or string)
    $author = $thing->author;
    // echo an attribute with the_* methods
    $thing->the_title();
    // get another Thing
    $parent = $thing->parent;
endforeach;

Each Thing automatically has properties and associated the_* methods for the standard WordPress data and taxonomies associated with that post type. Meta (custom field) properties are created when you specify meta in your custom post type arguments. If you want to add custom methods or properties, create a subclass of Thing and register that with a particular post type.