Created
April 26, 2025 02:55
-
-
Save pagelab/5b07baeda01af367b1f73379b92dd5e9 to your computer and use it in GitHub Desktop.
Custom taxonomy registration code for the “Books” Custom Post Type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment