问题
I added a custom post type to my wordpress theme. I related with category taxonomy, I can relate with the same categories as the posts. What I need is a custom category for my custom post type.
Eg: "book" for post type and book-category/fictional
I need it to be different than post categories. Is this possible?
回答1:
Yes sir it is possible!
http://codex.wordpress.org/Taxonomies
In a nutshell:
function register_book_genre_taxonomy() {
register_taxonomy(
'book_genre',
'book',
array(
'label' => __( 'Genre' ),
'rewrite' => array( 'slug' => 'genre' )
)
);
}
add_action( 'init', 'register_book_genre_taxonomy' );
来源:https://stackoverflow.com/questions/25127594/custom-category-for-custom-post-type