18

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/

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?

1
  • Did you ever find a solution for this that doesn't require a third party plugin? I am also looking for a way to do this without a plugin, since I am trying to write my own plugin that does it. Commented Mar 19, 2015 at 14:28

6 Answers 6

6

The functionality you want may be built from scratch but definitely a custom fields plugin will make your life much easier.

I use Advanced Custom Fields, and it gives amazing results and the possibilities are endless.

I haven't used this one, but it seems pretty good too.

2
  • I do use ACF for every Wordpress I'm working on and it will fit your needs (and much much more) perfectly
    – Kaaviar
    Commented Mar 22, 2012 at 12:25
  • Correction: what @Norcross offers is not a plugin, is a Class, and it is really 1st class for theme developers.
    – brasofilo
    Commented May 18, 2012 at 11:15
4

You can use this plugin http://wordpress.org/extend/plugins/multiple-post-thumbnails/ to add secondary featured image to page/posts header image.

1
  • I also use the Multiple Post Thumbnails plugins mentioned in a previous response and would recommend that as a good solution in this instance.
    – Ben Huson
    Commented Mar 22, 2012 at 11:42
2

I'm one of the developers that maintains this metabox class. it includes an upload field that you can use.

https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress

1
  • nice! i like this lib
    – Ayaz Malik
    Commented Aug 1, 2013 at 23:32
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.

0

use this "Meta Box Script For WordPress" http://www.deluxeblogtips.com/meta-box-script-for-wordpress/

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.