Object-oriented access to WordPress data. Typed model classes with lazily resolved properties, repositories for every read and write, and one Manager wiring them together — for posts, terms, users, comments, sites, menus, WooCommerce products and orders, and your own custom database tables.
Models hold the data, repositories talk to WordPress, the Manager wires them together.
use Wpify\Model\Manager;
use Wpify\Model\PostRepository;
$manager = new Manager();
$posts = $manager->get_repository( PostRepository::class );
// Read
foreach ( $posts->find_published() as $post ) {
echo $post->title;
}
// Write
$post = $posts->create( array( 'title' => 'Hello' ) );
$posts->save( $post );
echo $post->id; // result: the new post IDDefining a model for your own post type is a class and two attributes:
use Wpify\Model\Post;
use Wpify\Model\Attributes\Meta;
class Book extends Post {
#[Meta( meta_key: 'isbn' )]
public string $isbn = '';
}- Typed properties instead of
get_post_meta()calls — declare a property, annotate its source with a PHP attribute, and the library resolves, casts, and caches it lazily. - All WordPress I/O in one place — repositories wrap
WP_Query, meta APIs, and WooCommerce CRUD, so your business code never touches globals. - Custom tables without the boilerplate —
#[Column]attributes generate the schema, migrations run automatically, and a structured where-syntax replaces hand-written SQL. - Built for extension — every built-in model and repository is designed to be subclassed.
- PHP 8.0+
- WordPress (WooCommerce models require WooCommerce; Site models require multisite)
composer require wpify/modelFull documentation lives in docs/:
- New here? Installation → Quickstart — first success in about five minutes.
- Building something? Guides for custom post types, custom taxonomies, meta fields, relations, querying, custom tables, WooCommerce, and more.
- Looking something up? The reference covers every class and all 17 attributes.
- Something broken? Troubleshooting.
- AI agent? Start from
llms.txt.
GPL-2.0-or-later