Add to Post Type
You can add a taxonomy to any post type by passing the post type name to the posttype() method.
1
// Create the genre taxonomy.
2
$genres = new Taxonomy( 'genre' );
3
4
// Attach to the book post type.
5
$genres->posttype( 'books' );
6
7
// Register changes to WordPress.
8
$genres->register();
Copied!
Alternatively, you can attach a taxonomy to a post type when creating a post type using its taxonomy() method.
Last modified 3yr ago
Copy link