In your case, you need to add custom fields to the metabox. The full reference code of the filter is here: ‘admin_post_thumbnail_html’ – https://developer.wordpress.org/reference/hooks/admin_post_thumbnail_html/.
Let’s add an image title:
<?php add_filter('admin_post_thumbnail_html', 'custom_featured_image_field', 10, 2); function custom_featured_image_field($content, $post_id) { $custom_name = ‘custom_featured_image_title’; $custom_value = esc_attr(get_post_meta($post_id, $custom_name, true)); $output = sprintf( ‘<br><input type=“text” id="%1$s" name="%1$s" value="%2$s">', $custom_name, $custom_value ); return $content .= $output; }?>
Let’s save the newly added custom field
Here we will sanitize user data and save or update the custom featured image title field.
<?phpadd_action('save_post', 'save_custom_featured_image_field', 10, 3); function save_custom_featured_image_field($post_ID, $post, $update) { $custom_name="custom_featured_image_title"; $custom_value = isset($_REQUEST[ $custom_name ]) ? 1 : 0; update_post_meta($post_ID, $custom_name, $custom_value); }?>