Ask any question about WordPress here... and get an instant response.
Post this Question & Answer:
How can I create a custom post type with specific taxonomies in WordPress? Pending Review
Asked on Apr 14, 2026
Answer
Creating a custom post type with specific taxonomies in WordPress involves registering the post type and the taxonomies using WordPress hooks. This is typically done in your theme's `functions.php` file or a custom plugin.
<!-- BEGIN COPY / PASTE -->
function my_custom_post_type() {
$args = array(
'label' => 'Books',
'public' => true,
'supports' => array('title', 'editor', 'thumbnail'),
'has_archive' => true,
);
register_post_type('book', $args);
// Register a custom taxonomy
$taxonomy_args = array(
'label' => 'Genres',
'rewrite' => array('slug' => 'genre'),
'hierarchical' => true,
);
register_taxonomy('genre', 'book', $taxonomy_args);
}
add_action('init', 'my_custom_post_type');
<!-- END COPY / PASTE -->Additional Comment:
- Custom post types allow you to create different content types beyond the default posts and pages.
- Taxonomies help organize your content by grouping similar items together.
- Ensure your theme supports the features you enable (e.g., thumbnails).
- Use the "init" hook to register post types and taxonomies early in the WordPress loading process.
Recommended Links:
