Ask any question about WordPress here... and get an instant response.
Post this Question & Answer:
How can I create a custom post type with custom fields in WordPress?
Asked on Jan 18, 2026
Answer
Creating a custom post type with custom fields in WordPress involves registering the post type and adding custom fields to it. This can be done using code in your theme's `functions.php` file or through a plugin like Advanced Custom Fields (ACF).
<!-- BEGIN COPY / PASTE -->
// Register Custom Post Type
function create_custom_post_type() {
$args = array(
'label' => 'Books',
'public' => true,
'supports' => array('title', 'editor', 'custom-fields'),
'has_archive' => true,
);
register_post_type('book', $args);
}
add_action('init', 'create_custom_post_type');
<!-- END COPY / PASTE -->Additional Comment:
- Custom post types allow you to create content types beyond the default posts and pages.
- Use the "supports" parameter to enable features like custom fields, which can be managed in the post editor.
- For more advanced custom field management, consider using the Advanced Custom Fields (ACF) plugin.
- Always back up your site before making changes to `functions.php`.
Recommended Links:
