wp-orbit / post-types
There is no license information available for the latest version (dev-master) of this package.
WordPress post type helpers.
Package info
github.com/wp-orbit/post-types
Type:wordpress-plugin-component
pkg:composer/wp-orbit/post-types
dev-master
2017-10-06 15:42 UTC
This package is not auto-updated.
Last update: 2026-03-12 15:37:20 UTC
README
via WP Orbit
PostType Class
This package provides an extensible PostType class which abstracts creating custom post types.
Basic usage:
For each custom post type you need, extend the base PostType class, then call registerPostType().
<?php use WPOrbit\PostTypes\PostType; // Extend PostType class AuthorPostType extends PostType { protected function __construct() { $this->key = 'author'; $this->slug = 'authors'; $this->singular = 'Author'; $this->plural = 'Authors'; } } class BookPostType extends PostType { protected function __construct() { $this->key = 'book'; $this->slug = 'books'; $this->singular = 'Book'; $this->plural = 'Books'; } } // Hook into WordPress... AuthorPostType::getInstance()->registerPostType(); BookPostType::getInstance()->registerPostType();
Post Type Support
By default, the class is set to support: 'title', 'editor', 'author', and 'thumbnail'. Override $this->supports in the extending class' constructor to add other default functionality to your post type.
<?php protected function __construct() { $this->key = 'book'; $this->slug = 'books'; $this->singular = 'Book'; $this->plural = 'Books'; $this->supports = ['title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments']; }