PostTypes
PostTypes copied to clipboard
v3.0
v3.0
PostTypes v3 moves away from the old approach of building post types step-by-step using method calls, and instead adopts a class-based, declarative design. Rather than constructing post types imperatively—by calling methods line by line at runtime—developers now define them declaratively by extending an abstract PostType class and implementing specific configuration methods.
This change reflects a simpler and more maintainable philosophy: instead of building a post type procedurally, you now describe what a post type is. This aligns better with how post types are typically used—defined once and remaining consistent throughout an application.
Key changes
PostTypeis now an abstract class; post types are defined by subclassing and implementing methods likename(),options(),labels(), andcolumns(). The same is true for theTaxonomyclass.- Configuration is declarative—developers describe the post type’s structure instead of composing it step-by-step through method calls.
- Improves readability, testability, and removes the need to pass post type objects around the codebase.
- Designed for consistency, clearer tooling support, and easier static analysis.