Custom Post Type Creation

User
create custom post type to upload feature image only with title thats it
Assistant
To create a custom post type in WordPress that allows only a title and a featured image, you can add the following code to your theme's `functions.php` file or in a custom plugin:

### Steps:
1. **Register the custom post type** with support for only the `title` and `thumbnail`.
2. **Disable unnecessary fields** from the editor.

### Code:

function custom_featured_image_post_type() {
    $args = array(
        'label'               => __('Feature Image Post', 'textdomain'),
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'menu_position'       => 5,
        'supports'            => array('title', 'thumbnail'), // Only title & featured image
        'menu_icon'           => 'dashicons-format-image',
    );

    register_post_type('feature_image_post', $args);
}
add_action('init', 'custom_featured_image_post_type');

// Remove unnecessary meta boxes from the editor
function remove_extra_meta_boxes() {
    remove_meta_box('slugdiv', 'feature_image_post', 'normal'); // Remove Slug
    remove_meta_box('submitdiv', 'feature_image_post', 'side'); // Remove Publish box
}
add_action('admin_menu', 'remove_extra_meta_boxes');

### Features:
โœ… Allows only **title** and **featured image**
โœ… Hides unnecessary meta boxes
โœ… Adds a **custom post type** in the admin menu

Let me know if you need any tweaks! ๐Ÿš€

Leave a Comment

Your email address will not be published. Required fields are marked *