I would like to add multiple featured image in meta box in post editor area apart from default available featured image.
I have added the meta box but i have no idea on adding the featured image functionality.
function another_image_custom_meta() {
add_meta_box('another_meta', __('Another Image'), 'another_image_callback', 'another','side');
}
add_action('add_meta_boxes', 'another_image_custom_meta');
Where another in fourth field is my custom post type.
function another_image_callback($post) {
wp_nonce_field(basename(__FILE__), 'another_nonce');
$p_stored_meta = get_post_meta($post->ID);
?>
<p>
Another featured image
</p>
<?php
}
Above functions works fine it show the meta box.
How can i add the link with image upload and save it as featured image to the corresponding post. Like default featured image i want the same function here. can anyone help?
I know you said you were looking for your own implementation, but the easiest way to add multiple featured image metaboxes is with the Multiple Post Thumbnail plugin.
Following the plugin’s documentation, the way to define a secondary box is to add this code to your theme’s functions.php
and then to display the image in your theme somewhere: