Ask any question about WordPress here... and get an instant response.
How can I create a custom post type with custom fields in WordPress?
Asked on Nov 16, 2025
Answer
Creating a custom post type with custom fields in WordPress allows you to organize and manage specific types of content more effectively. This can be achieved by using WordPress functions and hooks in your theme's `functions.php` file or through a custom plugin.
<!-- BEGIN COPY / PASTE -->
// Register Custom Post Type
function create_custom_post_type() {
$args = array(
'label' => __( 'Books', 'text_domain' ),
'public' => true,
'supports' => array( 'title', 'editor', 'custom-fields' ),
'has_archive' => true,
'rewrite' => array( 'slug' => 'books' ),
);
register_post_type( 'book', $args );
}
add_action( 'init', 'create_custom_post_type', 0 );
<!-- END COPY / PASTE -->Additional Comment:
- Custom fields can be added to your custom post type using the "Custom Fields" option in the post editor screen.
- To manage custom fields more effectively, consider using a plugin like Advanced Custom Fields (ACF).
- Ensure your theme supports the display of custom fields by modifying the template files if necessary.
- Always back up your site before making changes to the `functions.php` file or database.
Recommended Links:
