PHPackages                             waughj/wp-post-type - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. waughj/wp-post-type

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

waughj/wp-post-type
===================

Simple class for easily creating new post types for a WordPress site.

v0.5.0(6y ago)085AGPL-3.0-or-laterPHPPHP &gt;=7.2

Since Jun 4Pushed 5y agoCompare

[ Source](https://github.com/waughjai/wp-post-type)[ Packagist](https://packagist.org/packages/waughj/wp-post-type)[ RSS](/packages/waughj-wp-post-type/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (4)Versions (13)Used By (0)

WP Post Type
============

[](#wp-post-type)

Simple class for easily creating new post types for a WordPress site.

Use
---

[](#use)

Just call constructor before admin loads. Constructor automatically calls all the WordPress functions needed to set it up, while you only need to pass in data.

1st 2 mandatory arguments to the constructor are the identifying slug &amp; the public name for the post type group. The optional 3rd argument is a hash map o' extra arguments:

- "singular\_name": Public name for single entry o' post type. ( If post type is "Boxes", you would make this "Box". ) Defaults to group name.
- "meta\_boxes": Array o' hash maps representing data for meta boxes that will automatically be setup. Hash maps should have values for "slug" &amp; "name" keys to be valid. Other optional key values are the same as the optional extra arguments for meta boxes listed below. "post\_type" value for each meta box will automatically be set to this post type 'less specifically set. ( This is mainly meant for backward compatibility with already-made meta boxes with slugs that don't fit pattern. 'Less a certain full slug is needed for meta boxes, I would recommend not bothering to o'erride this. )
- "meta\_box\_prefix": Overrides prefix that goes before slug o' each meta box slug when setting their full slug. Defaults to post type slug plus a hyphen separator.\*
- "custom\_toc": Array o' hash maps for columns to add to table view o' posts o' this type. Keys given values should be "slug" &amp; "name". "Slug" should refer to the meta box slug &amp; "name" should refer to the heading given to that column in the view.
- "unset\_toc": Array o' default columns for admin list view to take off table.
- "toc\_order": Array o’ column keys specifying custom column order.
- All arguments passed to WordPress register\_post\_type function. See [https://developer.wordpress.org/reference/functions/register\_post\_type/](https://developer.wordpress.org/reference/functions/register_post_type/) for more information.

Example
-------

[](#example)

```
use WaughJ\WPPostType\WPPostType;

new WPPostType
(
	'news',
	'News',
	[
		'singular_name' => 'News Article',
		'supports' => [ 'title', 'editor', 'thumbnails' ],
		'meta_boxes' =>
		[
			[
				'slug' => 'url',
				'name' => 'URL'
			],
			[
				'slug' => 'order',
				'name' => 'Order',
				'input-type' => 'number'
			]
		],
		'unset_toc": [ 'title' ],
		'custom_toc':
		[
			[
				'slug' => 'order',
				'name' => 'Order'
			]
		],
		'toc_order' => [ 'url', 'order', 'date' ],
		'taxonomies' => [ 'cat_news' ]
	]
);

```

Changelog
---------

[](#changelog)

### 1.0.0

[](#100)

- Add all register\_post\_type arguments to verified arguments list.
- Add sanitizers to inputs to add extra security.

### 0.5.0

[](#050)

- Add simple way to reorder table of contents columns
- Turn public methods used by WordPress into closure generators to keep public interface clean
- Clean up &amp; comment code

### 0.4.0

[](#040)

- Add simple way to add taxonomies to type

### 0.3.2

[](#032)

- Update TestHashItem dependency

### 0.3.1

[](#031)

- Make method getMetaBoxes not break due to missing function use statement

### 0.3.0

[](#030)

- Make table of contents row render function send column &amp; post ID to custom function

### 0.2.0

[](#020)

- Add getMetaBox Method
    - Add method for getting a meta box object by slug

### 0.1.5

[](#015)

- Fix TestHashItemString Use Statement Typo

### 0.1.4

[](#014)

- Add TestHashItem Dependency

### 0.1.3

[](#013)

- Update Dependencies
    - Require non-buggy version o' WPMetaBox

### 0.1.2

[](#012)

- Fix Use Statement Bug
    - Was missing use statement for TestHashItemString, causing function to break

### 0.1.1

[](#011)

- Fix Meta Box Implementation Bug &amp; Update Readme
    - Called Meta Box class using ol' interface, which is no longer in use. This fixes that
    - Adds mo' detailed instructions to readme

### 0.1.0

[](#010)

- Initial Version

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Recently: every ~63 days

Total

12

Last Release

2285d ago

PHP version history (2 changes)v0.1.0PHP &gt;=7.0

v0.4.0PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11161078?v=4)[waughj](/maintainers/waughj)[@waughj](https://github.com/waughj)

---

Top Contributors

[![jjwmezun](https://avatars.githubusercontent.com/u/24711797?v=4)](https://github.com/jjwmezun "jjwmezun (2 commits)")

---

Tags

typewordpresspost

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/waughj-wp-post-type/health.svg)

```
[![Health](https://phpackages.com/badges/waughj-wp-post-type/health.svg)](https://phpackages.com/packages/waughj-wp-post-type)
```

###  Alternatives

[webdevstudios/cmb2-attached-posts

Custom field for CMB2 for creating post relationships.

13565.5k](/packages/webdevstudios-cmb2-attached-posts)[alexis-magina/cmb2-field-post-search-ajax

CMB2 field type to attach posts to each others. Search with Ajax.

3913.4k1](/packages/alexis-magina-cmb2-field-post-search-ajax)[wpbp/cpt_columns

Improve the CPT list in the backend for your CPTs

218.3k](/packages/wpbp-cpt-columns)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
