PHP 8 attributes
Declare post types and taxonomies, never register them
A class and a few attributes replace the register_post_type() array. Auto-discovery finds the class and registers it: nothing to wire in a provider.
- Slug, singular and plural come from the class name:
BookReviewgivesbook-reviewand “Book Reviews”. - One attribute per WordPress argument, with a full reference.
- Discovery also covers hooks, REST routes and schedules, cached in production.
use Pollora\Attributes\PostType;
use Pollora\Attributes\PostType\HasArchive;
use Pollora\Attributes\PostType\Supports;
#[PostType]
#[HasArchive]
#[Supports(['title', 'editor', 'thumbnail'])]
class Event {}