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;
Related Posts:
- Using add_theme_support inside a plugin
- How to add multiple images to custom post type?
- How do I remove all the metaboxes for a custom post type?
- Get all posts from custom post type and insert in select input as metabox
- Detect meta value changes when post is updated (post_updated)
- WordPress metabox file upload in custom post [duplicate]
- Having trouble with custom post type / meta box
- How can I include meta box content when searching?
- Save or update data when custom post published
- update a post meta from a single table cell TablePress
- update custom post type meta from a shortcode
- Custom Meta Boxes – Nonce Issue – Move to trash issue
- Displaying Meta Box Image
- How to: add option to add more checkboxes on custom post type
- How to keep a check box in custom meta box for custom post type checked by default for add new post?
- Show metabox in custom-post-template depending on taxonomy term?
- how to set default value for checkbox in wordpress
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Displaying custom posts only if custom meta box’s date is not expired
- Displaying Metabox value (custom post type taxonomy)
- How to List Thumbnails based on Custom Categories
- Adding Meta Boxes while Registering a Post Type in a Class
- How can I display my custom metaboxes on a custom post template?
- Meta Box Only in CPT Edit Page, Not in Add New
- get_post_meta is returning image id
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- Metadata for a taxonomy – is there any WordPress way of doing this?
- Populate Custom Fields in a Custom Post Type?
- Insert Multiple Post with Same Publish Button
- Custom meta box data array: foreach not working correctly?
- Undefined Variable – Custom Post Type Meta
- Populate dropdown from one custom post type inside another custom post type
- How to check if user meta field is empty in conditional else statement
- How to set YouTube video as featured image?
- Getting meta in editor plugin, and event triggering issue
- A better way to add a meta box to custom post types
- Metabox not show in categories custom post type cmb2
- How to use TinyMCE Editor for one of my custom post meta field?
- Show Custom Post Type meta boxes only on Page Edit
- Adding a metabox on a CPT’s submenu page
- Wrap meta boxes & data handling for specific post types in classes?
- Can’t publish custom post type – “You are not allowed to edit this post.”
- Custom fields for custom post type
- Meta Data for Custom Post Type not saving
- Save Multiple Metabox values
- create custom meta box with default value
- Displaying a div from an assigned meta_value when on a page
- Issue on Working with Metabox – Checkbox to enable Sale Items
- Why do I have to press the “Update” button twice to save my meta box values?
- How to insert data into meta box from another plugin?
- Adding custom meta boxes to specified custom post type
- Values from meta-box not on $_POST
- Custom Meta Box returns no HTML
- Custom post type suddenly stoped working after WordPress 5 update
- How to Use Custom Meta Field Instead of CPT Title in Post URL
- link featured image to external link
- Problem with adding custom post type meta to header by plugin
- Creating alternate meta box context locations
- Is it possible to sort metabox teaxtarea values?
- Create a select metabox that the user can pupolate?
- How can I output WPAlchemy repeating fields meta values in my page template?
- Meta box data is saved but NOT displayed in the meta box text field. Why?
- Save Metabox Custom Field Value
- Meta box data not saving
- WP_Meta_Query object with conditionals
- Related posts meta_query CPT
- Meta box with front-end styling
- Sanitaizing Select Optin For Custom Post Type Metabox in WP
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- Cannot Save MetaBox Data in Custom Post Type
- Add a class to post_class if more than one post shares same meta_value_num
- Function to return values from metabox
- Add a meta field to the list of results for a custom post type
- Empty meta-box returns publishdate if no value is set?
- Custom Meta Box with variable number of fields
- Wp Meta Query does not work while simple Query Works
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- How to add a default predefined thumbnail when creating a brand new post?
- Show a custom post title in another custom post type in Meta box
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- WP_List_Table Inside Metabox Not Working on Clicking Search Button
- Getting data from dynamically allocated metaboxes within a custom post
- Get meta values from parent post and save in child post
- Admin metabox with custom post type dropdown option not update choosed input after saving
- Metaboxes in Loop
- How save custom meta type posts multicheck grouped by taxonomy (with CMB2) [closed]
- php output of generated custom metabox
- Custom meta box data not saving
- Collect custom post in a calendar
- Custom meta box in editor of custom post type not working
- Delete custom post type metadata without deleting the post in admin area
- Problem with ‘save_post’ hook not running
- Edit post meta direct from post.php?
- Not Able to Display Metabox Saved Checkbox and Selected option After Save/ Update
- Howto: use existing post_meta as options for a different metabox (checkboxes or list)
- Display a post count from a custom metabox selection
- Customized featured image doesn’t refresh in post admin metabox after upload/insert
- Post AND page parameter for WP function
- Use a Variable in update_post_meta as the $meta_key
- How to consume external API from WordPress post editor and display the response data in the custom field?