Skip to content
Simple WordPress custom post types.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
docs Typo and grammar issues that slipped through. Oct 28, 2018
examples update example to include Taxonomy class and methods Oct 15, 2017
src
tests remove textdomain and translation method Oct 11, 2017
.gitattributes
.gitbook.yml update docs and structure Aug 27, 2018
.gitignore initial commit Aug 19, 2016
.travis.yml update test scripts Oct 11, 2017
CONTRIBUTING.md Merge branch 'master' into docs/grammar Oct 28, 2018
Changelog.md bump version and update changelog Mar 27, 2018
LICENSE initial commit Aug 19, 2016
README.md Typo and grammar issues that slipped through. Oct 28, 2018
composer.json Use HTTPS by default for all links Oct 25, 2018
phpunit.xml add basic failing test Jun 21, 2017

README.md

PostTypes v2.0.1

Build Status Latest Stable Version Total Downloads License

Simple WordPress custom post types.

Requirements

Installation

Install with composer

Run the following in your terminal to install PostTypes with Composer.

$ composer require jjgrainger/posttypes

PostTypes uses PSR-4 autoloading and can be used with Composer's autoloader. Below is a basic example of getting started, though your setup may be different depending on how you are using Composer.

require __DIR__ . '/vendor/autoload.php';

use PostTypes\PostType;

$books = new PostType('book');

$books->register();

See Composer's basic usage guide for details on working with Composer and autoloading.

Basic Usage

Below is a basic example of setting up a simple book post type with a genre taxonomy. For more information, check out the online documentation here.

// Require the Composer autoloader.
require __DIR__ . '/vendor/autoload.php';

// Import PostTypes.
use PostTypes\PostType;

// Create a book post type.
$books = new PostType( 'book' );

// Attach the genre taxonomy (which is created below).
$books->taxonomy( 'genre' );

// Hide the date and author columns.
$books->columns()->hide( [ 'date', 'author' ] );

// Set the Books menu icon.
$books->icon( 'dashicons-book-alt' );

// Register the post type to WordPress.
$books->register();

// Create a genre taxonomy.
$genres = new Taxonomy( 'genre' );

// Set options for the taxonomy.
$genres->options( [
	'hierarchical' => false,
] );

// Register the taxonomy to WordPress.
$genres->register();

Notes

Author

Joe Grainger

You can’t perform that action at this time.