2017 © Pedro Peláez
 

wordpress-plugin-component post-types

WordPress post type helpers.

image

wp-orbit/post-types

WordPress post type helpers.

  • Friday, October 6, 2017
  • by zawntech
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Post Types

via WP Orbit, (*1)

PostType Class

This package provides an extensible PostType class which abstracts creating custom post types., (*2)

Basic usage:

For each custom post type you need, extend the base PostType class, then call registerPostType()., (*3)

<?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., (*4)

<?php
protected function __construct() {
    $this->key = 'book';
    $this->slug = 'books';
    $this->singular = 'Book';
    $this->plural = 'Books';
    $this->supports = ['title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments'];
}

The Versions

06/10 2017

dev-master

9999999-dev

WordPress post type helpers.

  Sources   Download