wp-orbit/post-types

There is no license information available for the latest version (dev-master) of this package.

WordPress post type helpers.

Installs: 6

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:wordpress-plugin-component

dev-master 2017-10-06 15:42 UTC

This package is not auto-updated.

Last update: 2024-05-09 07:06:23 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'];
}