Entity declares WordPress custom post types and taxonomies with a fluent, typed interface instead of the long argument arrays of register_post_type() and register_taxonomy(). Each option has its own method, boolean options get dedicated methods (public(), showInRest()…), and registration is hooked to init for you. It is built on Extended CPTs, so labels are generated from the singular and plural names, and admin columns and filters are one method away (adminCols(), adminFilters()).
Part of Pollora, the Laravel framework for WordPress. In a Pollora project it is already installed: declare post types and taxonomies with the
#[PostType]and#[Taxonomy]attributes instead, and Pollora registers them through this package.
composer require pollora/entityRequires PHP 8.2+ and WordPress.
use Pollora\Entity\PostType;
PostType::make('book', 'Book', 'Books')
->public()
->showInRest()
->hasArchive()
->supports(['title', 'editor', 'thumbnail'])
->menuIcon('dashicons-book-alt');use Pollora\Entity\Taxonomy;
Taxonomy::make('genre', 'book', 'Genre', 'Genres')
->hierarchical()
->showInRest()
->showInQuickEdit();make() returns the configured object and registers it on the WordPress init hook, so call it before init runs (in a plugin's main file or a theme's functions.php).
- Typed, fluent methods for the post type and taxonomy arguments, with dedicated methods for boolean options.
- Built on Extended CPTs.
- Hexagonal architecture that keeps the domain independent from WordPress.
- Tested with Pest, with WordPress functions mocked.
- Post types: creating and configuring custom post types.
- Taxonomies: creating and configuring custom taxonomies.
In a Pollora project, see Post types and Taxonomies on pollora.dev.
The package follows hexagonal architecture principles:
- Domain layer: the core model (
Entity,PostType,Taxonomy). - Application layer: services that orchestrate registration.
- Adapter layer: the WordPress integration adapters.
The domain layer has no external dependencies: it defines interfaces (ports) that the adapters implement.
composer testThis runs the Pest unit tests, PHPStan and Pint. WordPress functions are mocked:
tests/Helpers/helpers.php: global WordPress function mockstests/Helpers/ext_cpts_helpers.php: Extended CPTs namespace function mockstests/Helpers/wordpress_args_helpers.php: mocks for pollora/wordpress-argstests/bootstrap.php: test environment setup
Contributions are welcome: see the contributing guide. Report security issues privately, as described in the security policy.
Entity is open-source software licensed under the MIT license. © RuBee group