PHPackages                             jjgrainger/posttypes - 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. jjgrainger/posttypes

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

jjgrainger/posttypes
====================

Simple WordPress custom post types.

v3.0.1(2mo ago)382568.8k—6.9%46[1 PRs](https://github.com/jjgrainger/PostTypes/pulls)11MITPHPPHP &gt;=7.2CI passing

Since Aug 16Pushed 2mo ago20 watchersCompare

[ Source](https://github.com/jjgrainger/PostTypes)[ Packagist](https://packagist.org/packages/jjgrainger/posttypes)[ Docs](https://posttypes.jjgrainger.co.uk)[ RSS](/packages/jjgrainger-posttypes/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (14)Used By (11)

PostTypes v3.0.1
================

[](#posttypes-v301)

[![tests](https://github.com/jjgrainger/PostTypes/actions/workflows/tests.yml/badge.svg)](https://github.com/jjgrainger/PostTypes/actions/workflows/tests.yml) [![codecov](https://camo.githubusercontent.com/8f89186f629e3a102850b11067548bd3c75c5d664bdbf1f710df526d4855dd93/68747470733a2f2f636f6465636f762e696f2f67682f6a6a677261696e6765722f506f737454797065732f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d5347724b327844463436)](https://codecov.io/gh/jjgrainger/PostTypes) [![Latest Stable Version](https://camo.githubusercontent.com/7039ce0d48c22fb0fcc980183ab43d1d24d21d7c529f402f42f2be03845fcf0f/68747470733a2f2f666c61742e62616467656e2e6e65742f6769746875622f72656c656173652f6a6a677261696e6765722f506f737454797065732f737461626c65)](https://packagist.org/packages/jjgrainger/posttypes) [![Total Downloads](https://camo.githubusercontent.com/196b6a7f83015101bc859abe64760c4dd9fe492f9f3b61c9cc45e0823e8304b0/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f64742f6a6a677261696e6765722f506f73745479706573)](https://packagist.org/packages/jjgrainger/posttypes) [![License](https://camo.githubusercontent.com/d7283ad6ae26c10ea00ca16f3ed4c662b1a8ea5d15e98f797c5db704bb204998/68747470733a2f2f666c61742e62616467656e2e6e65742f6769746875622f6c6963656e73652f6a6a677261696e6765722f506f73745479706573)](https://packagist.org/packages/jjgrainger/posttypes)

> Modern PHP abstractions for WordPress post types and taxonomies.

Migrating from v2 to v3
-----------------------

[](#migrating-from-v2-to-v3)

> **Important**: v3.0 is a breaking release. Existing v2 post type and taxonomy definitions will not work without modification. Please review the migration guide in the [documentation](https://posttypes.jjgrainger.co.uk) on how to upgrade to version 3.

Requirements
------------

[](#requirements)

- PHP &gt;=8.1
- [Composer](https://getcomposer.org/)
- [WordPress](https://wordpress.org) &gt;=6.3

Installation
------------

[](#installation)

#### Install with composer

[](#install-with-composer)

Run the following in your terminal to install PostTypes with [Composer](https://getcomposer.org/).

```
$ composer require jjgrainger/posttypes

```

PostTypes uses [PSR-4](https://www.php-fig.org/psr/psr-4/) autoloading and can be used with the Composer's autoloader. See Composer's [basic usage](https://getcomposer.org/doc/01-basic-usage.md#autoloading) guide for details on working with Composer and autoloading.

Basic Usage
-----------

[](#basic-usage)

#### Create a custom post type

[](#create-a-custom-post-type)

Custom post types are defined as classes that extend the base `PostType` class. At a minimum, the `name` method must be implemented to define the post type slug. All other methods are optional and allow you to configure labels, options, taxonomies, admin columns, filters, and more as needed.

```
