Plugin Directory

Test out the new Plugin Directory and let us know what you think.
!This plugin hasn’t 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.


Maps @annotated PHP classes to custom post types, automatically adds relevant fields to the Admin GUI, and LINQ/ActiveRecord-like queries.

PostTypeBuilder is an Object Relational Mapper connecting directly into the WordPress engine, and provides handy scaffolding through the WordPress GUI, as well as data querying similar to LINQ and ActiveRecord (Book::find()->where(...)).

class Book extends Entity{
    /** @Property */
    public $number_of_pages;
    the_post(); $book = new Book($post);
    echo "<dt>" . $book->post_title . "</dt>";
    echo "<dd>" . $book->number_of_pages . "</dd>";

Included is the Addendum library to support @annotations.

This plugin saves no information on your system (no database tables, no temporary files). All information is supplied by you in your class files.

See Other notes for more info

Register classes

Any classes in wp-content/classes, where the filename (like class_name.php) corresponds to the classname (like ClassName), will be registered as a WordPress Custom Post Type.

Following example needs to be defined in wp-content/classes/book.php, and results in a registered post type being shown in the admin UI (but not publicly queryable):

namespace MyEntities;
use \PostTypeBuilder\Entity;

class Book extends Entity{

See Other notes for more info

Define properties

Any class properties prefixed by the annotational comment /** @Property */ will be registered as WordPress metadata, and form fields will appear in the edit/create screen of the post type corresponding to the property type.

Following example, building on the previous Book example class, will display a text form field in the edit/create post screen:

namespace MyEntities;
use \PostTypeBuilder\Entity;

class Book extends Entity{
    /** @Property */
    public $number_of_pages;

To enable the property to carry multiple values, use the = array() assignment:

/** @Property */
public $authors = array();

See Other notes for more info

Find entities

You can load entities in three ways.

(1) By post ID:

$book = new Book(21);

(2) By post object (useful in the loop):

global $post;

$book = new Book($post);

(3) By query:

$books = Book::find()->where("pages > (NUMERIC)", 10);

foreach($books as $book){ ... }

(Note that the query is executed lazily - ie. at the foreach statement)

Following code shows how to manipulate your entities:

$book = new Book();
$book->post_title = "Foo";

(Both post_object members and class properties are accessed in a unified way, but class properties have precedence)

See Other notes for more info

Extend the functionality

The plugin is designed to be extensible, so you can override form field generation for your classes, text representations (by overriding __toString), add your own property types, their form field generation, their text representation, you can hook into save events (and more...).

Requires: 3.0 or higher
Compatible up to: 3.3.2
Last Updated: 5 years ago
Active Installs: Less than 10


0 out of 5 stars


Got something to say? Need help?


Not enough data

0 people say it works.
0 people say it's broken.