PostTypes
  • PostTypes v2.2.1
  • Getting Started
  • PostTypes
    • Create a Post Type
    • Add Taxonomies
    • Filters
    • Columns
    • Menu Icons
    • Flush Rewrite Rules
  • Taxonomies
    • Create a Taxonomy
    • Add to Post Type
    • Columns
  • Notes
  • Contributing
  • Changelog
Powered by GitBook
On this page
  1. Taxonomies

Add to Post Type

PreviousCreate a TaxonomyNextColumns

Last updated 6 years ago

You can add a taxonomy to any post type by passing the post type name to the posttype() method.

// Create the genre taxonomy.
$genres = new Taxonomy( 'genre' );

// Attach to the book post type.
$genres->posttype( 'books' );

// Register changes to WordPress.
$genres->register();

Alternatively, you can attach a taxonomy to a post type when creating a post type using its method.

taxonomy()