Ask any question about WordPress here... and get an instant response.
Post this Question & Answer:
How do I create a custom post type with its own custom taxonomy in WordPress?
Asked on Feb 06, 2026
Answer
Creating a custom post type with its own custom taxonomy in WordPress involves using specific functions in your theme's `functions.php` file or a custom plugin. This allows you to organize content beyond the default posts and pages.
<!-- BEGIN COPY / PASTE -->
// Register Custom Post Type
function create_custom_post_type() {
$args = array(
'label' => 'Books',
'public' => true,
'supports' => array('title', 'editor', 'thumbnail'),
'has_archive' => true,
);
register_post_type('book', $args);
}
add_action('init', 'create_custom_post_type');
// Register Custom Taxonomy
function create_custom_taxonomy() {
$args = array(
'label' => 'Genres',
'hierarchical' => true,
);
register_taxonomy('genre', 'book', $args);
}
add_action('init', 'create_custom_taxonomy');
<!-- END COPY / PASTE -->Additional Comment:
- Custom post types and taxonomies enhance content organization by allowing you to categorize and display content in unique ways.
- Ensure you flush rewrite rules by visiting the "Permalinks" settings page after adding new post types or taxonomies.
- Consider using a plugin like "Custom Post Type UI" if you prefer a graphical interface for creating custom post types and taxonomies.
Recommended Links:
