Easy API to create Wordpress posttypes., (*1)
To install this package you have a couple of options., (*2)
require { "tkj/posttype": "1.*" }
Clone the git repository into your prefered destination in your theme directory and require the Posttype.php
in your functions.php
, (*3)
git clone git@github.com:tkjaergaard/Wordpress-Posttype.git
The API of this package is quite simple. Simply create a new instance of Tkj\Posttype
or use the facade Tkj\Posttype::make()
, (*4)
<?php use Tkj\Posttype; new Posttype($singular); Posttype::make($singular);
Argument | Required | Type | Description |
---|---|---|---|
$singluar | True | String | Singular name of the post type |
$plural | Optional | String | Plural name of the post type. |
$options | Optional | Array | Array of options. |
$labels | Optional | Array | Array of labels. |
The options and labels array uses the same structure as Wordpress reqister_post_type() function., (*5)
The default options are pretty basic and shoud fit your needs in most cases., (*6)
{ 'public': true, 'publicly_queryable': true, 'show_ui': true, 'show_in_menu': true, 'query_var': true, 'capability_type': 'post', 'has_archive': true, 'hierarchical': false, 'menu_position': null, 'supports': ['title', 'editor', 'thumbnail', 'excerpt'] }
The labes are generated from the singular and/or the plural arguments you use to create the post type. The labels are generated in english., (*7)
This package is released under the MIT license., (*8)
Thomas Kjaergaard @t_kjaergaard tkjaergaard.dk, (*9)