Purpose
This plugin serves as a reference implementation for WordPress developers, showcasing:- Service container architecture for dependency injection
- Custom post types with proper capability management
- Hierarchical content relationships (Artists → Albums)
- Taxonomy implementation
- Block editor (Gutenberg) integration with React
- REST API customization
Key Features
Custom Post Types
Artist and Album post types with custom capabilities, labels, and admin UI enhancements
Genre Taxonomy
Non-hierarchical taxonomy for categorizing albums by musical genre
Parent-Child Relationships
Albums can be associated with Artist posts using WordPress’s parent-child relationship model
Block Editor Integration
Custom React component for selecting parent artists directly in the block editor
Technical Requirements
- WordPress Version: 6.9 or higher
- PHP Version: 8.1 or higher
- Modern JavaScript: Uses
@wordpress/scriptsbuild process
Plugin Structure
Content Types
Artists (music_artist)
Represents musicians or bands. Features include:
- Custom capability type for granular permission control
- Archive page at
/artists - Support for title, editor, excerpt, thumbnail, and custom fields
- Non-hierarchical structure
Albums (music_album)
Represents music albums released by artists. Features include:
- Parent relationship with Artist post type
- Archive page at
/albums - Custom REST API field for parent artist
- Admin column showing associated artist
- Genre taxonomy support
Genres (music_genre)
A non-hierarchical taxonomy for categorizing albums:
- Tag-like behavior (non-hierarchical)
- Applied to albums only
- Archive pages at
/genres/{genre-slug} - Custom capabilities for term management
Architecture Highlights
The plugin uses a service container pattern with service providers, making it:- Modular: Each feature is encapsulated in its own service class
- Testable: Dependencies are injected, not hardcoded
- Extensible: Third-party developers can register custom services via hooks
- Organized: Clear separation between registration and bootstrapping logic
REST API Integration
The plugin extends WordPress’s REST API:- All post types are exposed via
show_in_rest => true - Custom
parentfield registered for albums viaregister_rest_field() - Allows block editor to query and update parent relationships
Next Steps
Architecture
Learn about the service container and application lifecycle
Custom Post Types
Explore the Artist and Album post type implementations
Taxonomies
Understand the Genre taxonomy implementation
Block Editor
See how the parent artist selector works
