1 comment

  1. 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

       if (class_exists('MultiPostThumbnails')) {
            new MultiPostThumbnails(
                array(
                    'label' => 'Secondary Image',
                    'id' => 'secondary-image',
                    'post_type' => 'post'
                )
            );
        }
    

    and then to display the image in your theme somewhere:

    if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image'); endif;
    

Comments are closed.