Skip to content

Instantly share code, notes, and snippets.

@pagelab
Created April 26, 2025 02:55
Show Gist options
  • Save pagelab/5b07baeda01af367b1f73379b92dd5e9 to your computer and use it in GitHub Desktop.
Save pagelab/5b07baeda01af367b1f73379b92dd5e9 to your computer and use it in GitHub Desktop.

Revisions

  1. pagelab created this gist Apr 26, 2025.
    35 changes: 35 additions & 0 deletions taxonomy-registration.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    <?php // Ignore this line if your functions.php already include it.
    function register_book_author_taxonomy() {
    $labels = array(
    'name' => 'Book Authors',
    'singular_name' => 'Book Author',
    'menu_name' => 'Book Authors',
    'all_items' => 'All Book Authors',
    'edit_item' => 'Edit Book Author',
    'view_item' => 'View Book Author',
    'update_item' => 'Update Book Author',
    'add_new_item' => 'Add New Book Author',
    'new_item_name' => 'New Book Author Name',
    'parent_item' => 'Parent Book Author',
    'parent_item_colon' => 'Parent Book Author:',
    'search_items' => 'Search Book Authors',
    'popular_items' => 'Popular Book Authors',
    'separate_items_with_commas' => 'Separate book authors with commas',
    'add_or_remove_items' => 'Add or remove book authors',
    'choose_from_most_used' => 'Choose from the most used book authors',
    'not_found' => 'No book authors found',
    );

    register_taxonomy( 'book_author', 'books', array(
    'labels' => $labels,
    'hierarchical' => true,
    'public' => true,
    'show_ui' => true,
    'show_admin_column' => true,
    'show_in_nav_menus' => true,
    'show_in_rest' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'book-author' ),
    ));
    }
    add_action( 'init', 'register_book_author_taxonomy' );