Add a Meta Box for uploading a SECOND Featured Image?

I’d like to add a meta box to my posts and page editor that will allow me to upload an image and use it as sort of a SECOND featured image. The idea is that my client will be able to upload an image to this meta box to customize the page/posts header image.

Here is an example of what the final result would be: http://gointrigue.com/locations-and-dates/

Read More

As you can see at the top of the page there is a large banner of a dancer. Right now this is hardcoded with CSS. I’d like for this to instead be editable by my client from within the WordPress post/page edit screen on a per page and per post basis.

How do I get started?

Related posts

Leave a Reply

6 comments

  1. You will have to add a meta box on the post/page edit pages. See the doc for add_meta_box. There is a detailed example here, along with how to handle/save the entered information. In the myplugin_inner_custom_box function, replace the text input with a file upload (and/or more fields if you want to). Handle the $_FILE array in the myplugin_save_postdata function.

  2. There are a number of plugins and scripts that others have referenced. The two I prefer as a developer are Meta Box and the Meta Box Class. Both of these do require that you mess with code to set the fields up, but if you are adding custom meta, you will be messing with code to display it anyway.

    Advanced Custom Fields is a nice plugin for smaller needs and does allow the addition of new fields on the fly, but each field ( and sub-field – repeaters ) is added as a unique field and for each field you add, the plugin adds 2 fields to the database ( the second being an identifier assigned by ACF. ) So if you are doing a query on a page to get 10 fields, you will actually be doing 20 database queries ( plus one more by ACF ) which can really add to DB query bloat. Use this one carefully.