Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So I was wondering if it's possible to dynamically create meta boxes in the post admin. I have a lot of data but don't want to hardcode every meta box needed in functions.php.

An example would be a custom post type for movies, I want to create different meta boxes for all the actors in the movie.

Is it possible to add meta boxes dynamically with the ability to add and delete them within the post admin?

Thanks!

share|improve this question
    
Any progress on that question? –  kaiser Jan 30 at 11:46
add comment

6 Answers

MetaBox control via a Dashboard UI:

Advanced Custom Fields - Excellent and easy.

Magic Fields 2 - I've used and am not a fan of it...

FWIW, I've never been a fan of creating metaboxes via a UI so I always use one of these two classes:

For WP Metabox PHP Classes:

CMB - My personal my favorite by Atchinson, Erickson, Norcross. It's quick and easy for most needs.

WPAlchemy - I'm also a fan of WPAlchemy because it include repeating fields and repeating field groups which CMB has talked about adding someday but has yet do (I think everyone's just been too busy to do it).

share|improve this answer
add comment

I had your same requirements for a site I am developing now. I used successfully the following two plugins to help creating custom post type and meta boxes directly in admin area: Custom Post Type UI and Custom Field Template.

The only required code is creating a page-.php inside you theme folder and then use code similar to:

<h1><?php echo get_post_meta($post->ID, 'Name', true); ?> "<?php echo get_post_meta($post->ID, 'Title', true); ?>"</h1>

to retrieve and format as you want the information provided in metaboxes.

share|improve this answer
add comment

It's possible using a Metabox class that handles most of the coding for you.

*If there is a better metabox class, I'd love to hear about it, though I am very happy with WPAlchemy.

I prefer using Jared Atchison and Bill Erickson's Custom Metaboxes and Fields for WordPress class. It is very extensible and the easy to use and expand upon.

My fork of it allows you to also create taxonomy select and taxonomy radio custom fields.

share|improve this answer
    
I'm wondering that the Custom Metaboxes and Fields class is taken from my original class here: deluxeblogtips.com/p/meta-box-script-for-wordpress.html (with some modifications and improvements). The authors don't leave any credit to me, anyway. –  Rilwis May 14 '11 at 9:06
add comment

I would seriously consider looking into the WPAlchemy metaboxes class. It does exactly what you are after and so much more.

http://www.farinspace.com/wpalchemy-metabox/#have_fields_and_multi

This class is so great that I am frankly shocked that there is not a lot more discussion about it. *If there is a better metabox class, I'd love to hear about it, though I am very happy with WPAlchemy.

share|improve this answer
add comment

This could also be done using JavaScript. Just have it dynamically create additional fields and then have them all target the same destination array. So the fields created by the JavaScript would be named something like this:

<input type="text" name="actors[actor1]" id="actors[actor1]" />
<input type="text" name="actors[actor2]" id="actors[actor2]" />
<input type="text" name="actors[actor3]" id="actors[actor3]" />

The action to create these client-side fields could just be attached to an "Add Actor" button or something along those lines.

share|improve this answer
    
This looks promising though my knowledge of JA is limited, perhaps a working code snippet for some practice would be great. Thanks Hereswhatidid! –  Marco Apr 14 '11 at 14:42
    
Marco, check out wordpress.stackexchange.com/questions/19838/… –  Amanda Jul 18 '11 at 16:18
add comment

Yes its possible, Take a look at Verve Meta Boxes plugin

Once installed, you will find a configuration screen located under Tools in the left navigation. There you can create multiple meta boxes each with a set of user defined drag and drop sortable custom fields. See the screenshots for more detail.

share|improve this answer
    
Thanks Bainternet, I actually tried that plugin as a solution but it doesn't work for what I'm looking for. I appreciate the help! –  Marco Apr 14 '11 at 14:40
    
Another plugin that enables something similar is Magic Fields. You could have a look at how they use JS to duplicate Meta Fields. –  Milo May 13 '11 at 21:42
    
The problem with link-only answers: Link rot. The plugin is gone... –  kaiser Jan 30 at 11:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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