Music Genre Taxonomy
The Genre taxonomy (music_genre) is a non-hierarchical taxonomy (like tags) used to categorize albums.
Registration
Registered ininc/Content/Genre.php:36
Parameters
The taxonomy identifier
Post types this taxonomy applies to. Currently only assigned to
music_albumWhether the taxonomy is publicly accessible
Display UI for managing terms in the admin
Enables the REST API endpoint at
/wp-json/wp/v2/music_genreGenres behave like tags (non-hierarchical) rather than categories
Display a column for this taxonomy in the album list table
Allow genre tag cloud widget
Query variable for filtering by genre
Capabilities
The taxonomy uses custom capabilities for permission management:inc/Content/Genre.php:50-55
manage_music_genres
Ability to manage the genre taxonomy
edit_music_genres
Permission to edit genre terms
delete_music_genres
Permission to delete genre terms
assign_music_genres
Permission to assign genres to albums
Labels
The taxonomy includes comprehensive labels for the admin interface:All Labels
All Labels
inc/Content/Genre.php:56-78URL Rewrite Rules
Genre archive pages use custom URL structure:inc/Content/Genre.php:81-86
URL slug for genre archives (
/genres/{genre-slug})Do not prepend the front base to genre permalinks
Non-hierarchical URL structure (flat, not nested)
No endpoint mask applied
Usage Examples
Query Albums by Genre
Get Genres for an Album
REST API Access
Admin Interface
Update Messages
Custom admin messages for genre operations:inc/Content/Genre.php:93-107
Admin Column
Sinceshow_admin_column is set to true, a Genres column automatically appears in the Albums admin list table, displaying all genres assigned to each album.
Technical Details
Registration Hook
Registration Hook
The taxonomy is registered on the This ensures it’s registered before the default priority of
init action with priority 9:10, allowing other hooks to properly reference the taxonomy.Source: inc/Content/Genre.php:26Non-Hierarchical Behavior
Non-Hierarchical Behavior
By setting
hierarchical to false, genres behave like WordPress tags:- Multiple genres can be assigned to a single album
- No parent-child relationships between genres
- Text input with comma separation in the editor
- “Popular Genres” and “Choose from most used” functionality
- Tag cloud support for widgets
