PostTypes
GitHub
Travis CI
Packagist
Search…
PostTypes v2.2
Getting Started
PostTypes
Create a Post Type
Add Taxonomies
Filters
Columns
Menu Icons
Flush Rewrite Rules
Taxonomies
Notes
Contributing
Changelog
Powered By
GitBook
Add Taxonomies
You can add new and existing taxonomies to a post type by passing the taxonomy name to the
taxonomy()
method.
1
// Create a book post type.
2
$books
=
new
PostType
(
'book'
);
3
4
// Add the genre taxonomy to the book post type.
5
$books
->
taxonomy
(
'genre'
);
6
7
// Add the default category taxonomy.
8
$books
->
taxonomy
(
'category'
);
9
10
// Register the post type to WordPress.
11
$books
->
register
();
Copied!
This method only attaches the taxonomy to the post type, to
create
a taxonomy see the
documentation
on creating a new taxonomy.
Taxonomies and post types can be created in any order.
Previous
Create a Post Type
Next
Filters
Last modified
3yr ago
Copy link