Meta Box Script Update V3.0

Meta Box Script Update V3.0

Update: The script was turned into Meta Box WordPress plugin and is being developed. Visit plugin page to see more info and download latest version.

After 2 posts in series of creating meta box, I received many ideas and opinions that really helpful. I appreciate that, and I want to give big thanks to all our contributors.

It has been a while since the last version of meta box script (2.4.1). Today I want to show you the next major version (3.0) with many improvements in the code, which supports better for OOP, gives big opportunity to developers to extend the class. And of course, some field types are added as well as some bugs are fixed.

Let’s go a bit in details.

Better support for Object-Oriented Programming

One of the major changes in this version is the class supports better for OOP. All functions for checking, showing and saving fields are separated in methods. For example, to check the upload field, there is a group of methods:

function __construct($meta_box) {
// Check field upload and add needed actions
function check_field_upload() {
 if ($this->has_field('image') || $this->has_field('file')) {
  add_action('post_edit_form_tag', array(&$this, 'add_enctype'));    // add data encoding type for file uploading
function show_field_file($field, $meta) {
function save_field_file($post_id, $field, $old, $new) {

There’re some advantages of this style of coding:

Allow developers easily to extend the class

Imagine that you want to extend the class that support another field type, for example link. All you need is defining corresponding methods that check, show and save this type of field. That’s very similar to the code above.

In the download package, I also created an example to make this idea clearly. The class RW_Meta_Box_Taxonomy extends the class RW_Meta_Box, adds taxonomy type of field. You should read it carefully to know how to replicate for other types. Thank Manny Fresh for the code for taxonomy type.

1. The name of showing and saving methods should be show_field_{$type} and save_field_{$type} correspondingly.
2. Note that the original class has a common save method save_field that can handle most cases of saving field. If you don’t write any method for saving field value (i.e. save_field_{$type} method), then save_field will be used.

Allow developers to re-define the look and feel of fields

If you don’t like the appearance of fields, feel free re-define it. Just overwrite the written showing method.

For example, each field is showed in 2 cells of a row in the table. If you don’t want 2 cells, but only 1 cell, you can re-define it like this:

class RW_Meta_Box_New extends RW_Meta_Box {

 // show uploaded images in 1 cell, overwrite original method
 function show_field_image($field, $meta) {
  global $post;

  echo "<td colspan='2'>{$field['name']}<br />";

  // show attached images
  $attachs = get_posts(array(
   'numberposts' => -1,
   'post_type' => 'attachment',
   'post_parent' => $post->ID,
   'post_mime_type' => 'image', // get attached images only
   'output' => ARRAY_A
  if (!empty($attachs)) {
   $nonce = wp_create_nonce('rw_ajax_delete_file');

   echo '<div style="margin-bottom: 10px"><strong>' . _('Images attached to this post') . '</strong></div>';
   foreach ($attachs as $att) {
    $src = wp_get_attachment_image_src($att->ID, 'thumbnail');
    $src = $src[0];
    echo "<div style='margin: 0 10px 10px 0; float: left'><img width='150' src='$src' /><br />
      <a class='rw-delete-file' href='javascript:void(0)' rel='{$att->ID}-{$nonce}'>Delete</a>

  // show form upload
  echo "<div style='clear: both'><strong>" . _('Upload new images') . "</strong></div>
   <div class='new-files'>
    <div class='file-input'><input type='file' name='{$field['id']}[]' /></div>
    <a class='rw-add-file' href='javascript:void(0)'>" . _('Add more image') . "</a>

Easily to contribute

The idea of separating methods came to me when I saw the way our contributors added features to the class. All of them have to change code directly. So, each developer has his own version of the script, and all the works of combining them falls down on my shoulders. It’s hard, yes, and buggy because I’m not sure if there’s no errors while doing it.

So, with this version, I hope all developers have a basic solid and reliable fundamental, that you can sit on and do all the extending works without worrying about other people. Perhaps each of you can have an (or many) extended class, but it will be very easy to share it with other developers. They don’t have to look into every line of code to find where you changed.

And I hope you will contribute your extended classes here in the comments, and maybe in the next version, I’ll release them as modules to give ability plug-and-play to users.

Added some new field types

In response to many requests of supporting new field types, I added these fields in this version:
date, time, color with the picker, of course. I use jQueryUI at Google CDN, and the timepicker addon by Trent Richardson.
checkbox list, credit to Jan Fabry.
taxonomy was added as an example of extending the class, credit to Manny Fresh.

Each new types have some options that you should read in the meta-box-usage.php file in the download package. I left many comments in this file that I believed you can understand without any efforts.

Meta Box Script Update V3.0

Added some features for old field types

There’re some slightly changes for old types, such as:
– change the way of definitions of options for radio, select fields to make it simpler and more appropriate.
– add multiple option for select field, allow users select multiple options.
– show uploaded files as well as allow users add/delete attached files
– delete attached files when post is deleted (credit to Kai)

And the validation function MUST return field value instead of boolean value.

Code bug fixes and improvements

There were some bugs in old code that show warnings when turn on debug mode in WordPress by define('WP_DEBUG', true); in wp-config.php file.

Some code were also changed to make it shorter and more clearly.

How to show custom meta fields on website?

This basic question is asked many times. And I’m sorry to not writing this at the beginning of the series.

Get value of field with single value

Most fields have single value (this is the default option). To get the value of field, use this code:

$meta = get_post_meta(get_the_ID(), 'meta_key', true);
echo $meta; // if you want to show

The last parameter true indicates that our field has single value.

The meta_key is the ID of meta field that has been registered. For example, if you registered a field with:

$prefix = 'rw_';
 'name' => 'Full name',
 'id' => $prefix . 'fname',
 'type' => 'text'

Then meta_key is rw_fname. Note that it is prefixed.

For more information about get_post_meta(); please read the Codex.

Get value of field with multiple values

There’re some fields that may have multiple values such as select, checkbox_list. To get (or check) values of these fields, use this code:

$metas = get_post_meta(get_the_ID(), 'meta_key', false);

// if you want to show values
foreach ($metas as $meta) {
 echo $meta;

// if you want to check if a value $val is set or not
if (in_array($val, $metas)) {
 echo "$val is set";
} else {
 echo "$val is not set";

The code is very similar to the one above. The different is the last parameter, which now is false, that means our field doesn’t have single value (ie it has multiple values).

Get uploaded files

Updated: Since version 3.0.1, uploaded files’ urls are saved as a field with multiple values. So, you can use the code for getting field with multiple values above. The old code below still works, but it will get all attached files to this post (maybe there’re some files you uploaded in the editor, not in the meta box).

To get uploaded files of a post, use this code:

$attachs = get_posts(array(
 'post_type' => 'attachment',
 'post_parent' => get_the_ID(),
 'numberposts' => -1
if (!empty($attachs)) {
 foreach ($attachs as $att) {
  if (wp_attachment_is_image($att->ID)) continue; // don't show attached images

  echo '<p>' . wp_get_attachment_link($att->ID) . '</p>';

This code will show links to each uploaded files using wp_get_attachment_link(); function.

There’re various functions at the Codex for attachments that you might be interested in.

Get uploaded images

Updated: Since version 3.0.1, uploaded images’ urls are saved as a field with multiple values like uploaded files. So, you can use the code for getting field with multiple values above. The old code below still works, but it will get all attached images to this post (maybe there’re some images you uploaded in the editor, not in the meta box).

To get (and show) uploaded images, use this code:

$attachs = get_posts(array(
 'numberposts' => -1,
 'post_type' => 'attachment',
 'post_parent' => get_the_ID(),
 'post_mime_type' => 'image', // get attached images only
 'output' => ARRAY_A
if (!empty($attachs)) {
 foreach ($attachs as $att) {
  // get image's source based on size, can be 'thumbnail', 'medium', 'large', 'full' or registed post thumbnails sizes
  $src = wp_get_attachment_image_src($att->ID, 'full');
  $src = $src[0];

  // show image
  echo "<div style='margin: 0 10px 10px 0; float: left'><img src='$src' /></div>";

This code will show all attached images to the post.

A short way to do this is use the [gallery] shortcode. It is a built-in WordPress shortcode that you can use immediately. For more information about this shortcode, please read the Codex.

Another way to achieve this is using a plugin. A famous plugin for getting image of post is Get The Image, written by Justin Tadlock. It has many options and easy to use.

Hope this guide help you when using the Meta Box script.

This post is the first part of meta box series:


  1. brilliant, been using this my plugins/themes for a while and had to customize the class for my specifi purposes.

    thank you soo much for updating the class.

    1. Hi Jez, I don’t understand what you mean “custom order, to the uploaded images”. What did you try to say?

    2. Kai also added the option to drag around the images once uploaded, and then this is the order they are displayed once printed on the live site… Not jus the order they are uploaded in with no option.

  2. Hi, I’ve read through the three posts relating to this code but I’m confused now as to how to implement a meta box based on this version 3 script. Can you point to an example of the code required to actually add a metabox to a page?

    1. Rick, all the example of using the code is included in the meta-box-usage.php in the download package. Just download it and you’ll see how to use the script for meta box.

    2. Thanks for the quick reply! Sorry, I’ve looked at that file but it looks as though that’s just extending the functionality of the original code. I’m just trying to figure out the code required to specifically add a metabox to a page. Is that actually in that file and I’m just misunderstanding how it works?

      I’ve added the main php code to my functions.php file and I also tried adding the sample in the meta-box-usage.php file but I don’t see anything added to posts / pages on my site. Sorry, maybe I’m being a bit brain dead here!

    3. Just look down a bit further. You’ll find the code of definition of meta boxes right after the extending class. The file looks like this:

      – extending class
      – definition of meta boxes
      – regiter meta boxes
      – validation class

    4. Thanks again for your reply, I’ll take a further look at it! I’m wondering if I’m somehow placing this in my functions.php file incorrectly? I’m including it at the end of the file after some other code I’ve written, is this correct?

    5. Yes, it’s correct, but you better including the class and the definition file using code in functions.php file:

      include THEMEPATH . ‘/meta-box.php’;
      include THEMEPATH . ‘/meta-box-usage.php’;

      This will keep you functions.php cleaner. And when you want to change meta boxes, just change in meta-box-usage.php, that’s all.

    6. Thanks again for your reply, I’ll take a further look at it! I’m wondering if I’m somehow placing this in my functions.php file incorrectly? I’m including it at the end of the file after some other code I’ve written, is this correct?

    7. Thanks again! 🙂 Sorry, comment threading seems to be a bit weird so I couldn’t reply directly to your most recent comment. Basically I have added includes to the two files in my functions.php as you suggested:

      include THEMEPATH . ‘/meta-box.php’;
      include THEMEPATH . ‘/meta-box-usage.php’;

      However, I still don’t see any metabox appearing on my pages or posts. I haven’t edited the meta-box-usage.php file as I presume the sample metabox should be displayed, but I don’t see it at all! Any idea what else could be the problem?

      Thanks again for taking time to reply, I appreciate it!

    8. Oh, sorry, I made a stupid mistake about the template path constant. Try this:

      include TEMPLATEPATH. ‘/meta-box.php’;
      include TEMPLATEPATH. ‘/meta-box-usage.php’;

    9. As a heads up you may need to use:
      include STYLESHEETPATH . ‘/meta-box.php’;
      include STYLESHEETPATH . ‘/meta-box-usage.php’;

      If you want to use the include in a child theme. TEMPLATEPATH refers to the parent.

    10. Thanks for your help, I’ve added this code to the very start of my functions.php file and that now seems to be working! Hopefully all good from here on! Thanks again!

  3. Hi,

    I’m getting this error: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’

    I’m assuming I’m doing something incorrectly.

    Thanks for your help.

    1. Yes, I think so, too. But I don’t know where you made mistake. The link 32 is very simple in meta-box.php file, and I’m sure there’s no error on it.

      If you do copy and paste, try doing the other way by including files, like in my response to Rick Curran above.

    2. Hi again,

      I’ve included the files as you suggested to Rick. Not sure what I could be doing wrong. I simply included the down load files and called them in my functions page. I’m calling other files as well with no problems, and have developed several themes using this method. I’m confused 🙁

      Thanks for your help

    3. That’s so weird. Rick was successful with that. What’s exactly the error message you got?

    4. Here’s the error message:

      Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /nfs/c03/h05/mnt/51370/domains/ on line 32

    5. I have exactly the same problem, the error point to the line

      protected $_meta_box;

      Can it be the PHP version..?

    6. Since I was only developing on this site, the PHP version was only version 4. I upgraded it to PHP5, and am now receiving this error:

      Parse error: syntax error, unexpected ‘;’, expecting T_FUNCTION in /nfs/c03/h05/mnt/51370/domains/ on line 573

      Progress, though.

    7. Sorry for not mentioned that the script works only for PHP5. Although, I’ve tested it again on my localhost with WP 3.1 (upgraded) and it works. I’ll test it with a fresh installation and see if there are some problem similar to yours.

  4. Loving this script! I know there are a lot of plugins addressing this functionality, like verve meta boxes, but I always opt for a non-plugin solution when I can. I do this especially for things that I don’t necessarily want a back-end admin changing at all.

    I did want to know if there was a way to hook the image uploader into the WordPress core image editor so that uploaded images could be cropped outside of the media library. Like maybe just a link when you hover over each image that reads ‘edit’ that would pull up that modal window like when you add images in the Text Editor via the gallery?

    I realize that a user could just go to the Media > Library section to do this but if there’s an easy way to add that link that I’m not seeing I’d be really appreciative of suggestions.

    Thanks again!

  5. I’d also like to know about ordering the uploaded images that I upload… is this possible? Jez, is this what you meant and if so, do you know how to do it?


  6. Sorry, me again. This is totally unrelated to my other two questions and more of a bug report.
    I’m using WordPress 3.1, fresh install (not upgraded). I’ve included both the meta-box.php and meta-box-usage.php files at the very bottom of my functions.php file.

    When I include these files, the contextual menus at the top of my custom post type edit pages break.

    FireBug reports a JavaScript error of: container is undefined
    return container.farbtastic || (cont… $._farbtastic(container, callback)); in

    I’ve narrowed it down to JUST the meta-box-usage.php file. I’m fairly certain it’s nothing I’ve added there, as I’ve commented all my code out and put it back to how it was on fresh download. Not sure what’s causing the error but I’ll report back here if I find out what it is.

    1. UPDATE:
      I’ve narrowed this down further to the third meta_boxes[] call. I started commenting out each field array one-by-one and it’s being caused by the type color field. Leaving everything else as is and just removing this type color call allows me to see my contextual menus again. Even if this type isn’t being called on my Custom Post Type it is messing it up.

      Could there be something conflicting with the internal jQuery functionality of WordPress and this custom color picker functionality?

      Note that this only causes an error on Custom Post types for me, though I haven’t tested that 100% thoroughly.

    2. Thank you so much for all bug reports.

      The color picker script I took from WP itself (as we see it in the Custom Background page). I’ll check why it conflicts with other libraries.

    3. I got this error after upgrading to wp 3.1.3.
      Looks like its line 255 in meta-box.php causing the error.

    4. I was just fussing with this. This thing happens when you’re on an edit page in WordPress’s admin that doesn’t have the color field, but where you’ve included the color field for other edit pages. So for example, if you have a color field in your “posts” edit page, but you don’t have a color field in your “page” edit page, this will throw a javascript error on the “page” edit page. In meta_box.php, at line 118, there is a check to find out if there is a color field on the page:

      if ($this->has_field(‘color’) && $this->is_edit_page()) {

      Apparently it’s returning true whether the color field is there or not. Thus, even when there is no color field, the javascript for the color picker gets enqueued and written into the head of the document. The javascript then goes looking for the color field (the javascript is on line 139):


      So the farbtastic function is looking for an element with a ID of whatever is in the $id variable. Effectively it’s looking for the color picker field, which should have the ID corresponding to what’s in that variable. But since that element isn’t on the page, the javascript can’t find it, and throws an error. My quick fix for this was just to write a little fail-safe line into the javascript before line 139:

      if(jQuery(‘#$id’).length < 1) {return;}

      That prevents the rest of the javascript for the color picker from running if the color field can't be found in the DOM. Of course, a better solution would be to figure out why that "has_field('color')" function is returning true, but I didn't want to muck with it too much. I hope this is helpful to anyone who is still interested (I realize this thread hasn't been touched in nearly a year, after all), either to fixing the bug or writing a workaround for it.

    5. Hi Matthew,
      Thanks for your explanation. It’s great. You’re right about the enqueuing scripts on wrong pages. The plugin now enqueues JS & CSS on all editing pages, which is redundant and may causes problems like this.

      But in the latest version (4.1.2), I think the JS code has been updated, which has a technique similar to yours. It may fixes the problem, I guess.

  7. how can i get image link or file link in my post template ?

    this doesn t work :
    ID, ‘services_image’, true); ?>

  8. Having two problems:
    1. When I upload a photo to the main content editor, it gets added with the photo upload area in the custom meta boxes – anyway of stopping that?

    2. How can I get the photos to appear on my page. Sorry, not sure which code I should be using.

    1. Hi Adam,

      1. Since the script using default image uploader, then it works with all attached images. I’m considering about your request, and I’m thinking of a solution for that: that is saving uploaded images urls in a meta fields with multiple values. I’ll finish the idea and get the script updated.

      2. I’ve just updated the post with guide to get (and show) meta values, including images. Hope this helps.

    2. Hi Adam, I’ve just updated the script and the article that works for only uploaded images. Please check it out.

  9. Hi, thank’s for this and all your hard work, this code is amazing. I’m using the new option to upload images and i want to create a widget to display popular posts in my site, but i was wondering how can i add the post id instead of the parent id, (‘post_parent’ => get_the_ID(),).

    Thank’s again

    1. The function get_the_ID() always returns the ID of current post in the loop. You also use global $post variable and access to its ID via $post->ID. These are 2 popular ways doing this.

  10. The date fields are not showing the stored values, it always show as “today”, if that makes any sense.
    If I set a date, say 2011-06-06 and save, when it reloads (or when you edit), it shows as today, 2011-03-06, despite the input value (and custom meta) being correctly set as 2011-06-06.
    I guess it’s something with datepicker’s options

    1. Yes, you’re right. I’ve just realized this problem. I’m playing with datepicker’s options, but still haven’t found any solution. Can anyone good at jQuery UI help me?

    2. Hi Rilwis, It was something with how do you set the default format. I don’t know if this is the best way but i got it working like this:

      function add_script_date() {
      $dates = array();
      foreach ($this->_meta_box[‘fields’] as $field) {
      if (‘date’ == $field[‘type’]) {
      $dates[$field[‘id’]] = isset($field[‘format’]) ? $field[‘format’] : ‘yy-mm-dd’;
      echo ‘

      foreach ($dates as $id => $format) {
      echo “$(‘#$id’).datepicker({ dateFormat: ‘”.$format.”‘ });”;
      echo ‘


    3. Thank you Erick. I’ve found the solution the same as you posted :). And the
      script is already updated with this fix. Thank you anyway, I appreciate

  11. Would it be possible to allow the uploaded image to be a custom field, rather than an attachment? That would be a great help to me!

    Thanks for any help,


    1. Hi Justin, this is done in new version. I’ve just updated it. Please check it out and let me know if you still have problems.

  12. Hi, i’m not able to display the values of the checkbox_list, i’m using your code but nothing is displayed

    1. Thanks for your report. Actually, there’s an error on my meta-box-usage.php file (in function add_missed_values). This make all fields not have multiple values (including checkbox_list). I’ve just reuploaded the files with fixes. Please download again and try it.

      (The entire class is not changed)

  13. Thanks again for your great work!

    Silly problem! I have two different Custom Post Types on a site. Once based on the 2.4.1-Version of the Metabox-Script and it works fine. The second now try to use this new 3.0. But, at the moment I include it, all metaboxes of the first one are disappearing. By the way, it makes no difference if I include the 2.4.1 or the 3.0 version. I’ve try to prefix or rename all functions, but it doesn’t fix.

    Have you any idea what the problem could be?

    1. I think so:

      add_action(‘init’, ‘create_post_type’);
      function create_post_type() {
      arry( and so on …

      And the meta box:

      $meta_box = array(
      ‘id’ => ‘my-meta-box_we’,
      ‘title’ => ”,
      ‘page’ => ‘my-custom-post-type’,
      and so on …

      For the second post type I use different names.

    2. Oh, you should wrap ‘page’ attribute of a meta box in an array, like this:

      $meta_box = array(
      ‘id’ => ‘my-meta-box_we’,
      ‘title’ => ”,
      ‘page’ => array(‘my-custom-post-type’),

    3. Hello Rilwis,

      thanks for your help. But your suggestion »’page’ => array(‘my-custom-post-type’),« results in many PHP-Errors. Without the array, it works fine but just as long as I have no second CustomPostType with other Meta-Boxes added.

    4. Ah, sorry, the key should be ‘pages’ => array(‘my-custom-post-type’) (note
      “pages” vs “page”). You can reference to my meta-box-usage.php for more

  14. Words cannot describe how happy I am right now! This class has helped me so much, I have been struggling with and image upload metabox which generates the 3 defale sizes set in wordpress, and it has been giving me all sorts of troubles.

    Thanks man your life saver

  15. Hi again,

    I’d like to report a pretty serious problem… though it may be something I’m doing. I “installed” by placing it in a functions folder inside my theme directory and call it using:
    include TEMPLATEPATH. ‘/functions/meta-box.php’;
    include TEMPLATEPATH. ‘/functions/meta-box-usage.php’;

    Now, that was working absolutely fine and my custom posts are able to have extra fields, etc (except for the color field since it conflicts with the contextual help/screen options panel as I’ve noted in my other comments).

    Anyway, I don’t want any special field on my post and pages so I just deleted the default example meta boxes from the meta-box-usage.php file. This is when my normal Posts and Pages start acting funny:
    – Whenever I update or add a new page or post it goes to a the WordPress failure notice page that reads “Are you sure you want to do this?” with a link “Please try again.” that leads back to the Post or Page.

    – Upon going back to edit the page or post, the changes did in fact save…but this is obviously not going to work on a live site with people editing it getting this screen every time they try to create or update a blog entry or page.

    When I put the default meta box sample code back in, my posts and pages save normally…but I don’t want those fields there! I also though it could be from getting rid of those before emptying the fields..but I’ve even tried creating new posts and pages after the code has been commented out.

    Any ideas?

    1. UPDATE: I commented out the line at the very bottom of the meta-box definitions within the foreach loop:
      $my_box = new RW_Meta_Box_Taxonomy($meta_box);

      Now it seems to work again normally.

      This is another weird thing: If I get rid of the RW_Meta_Box_Taxonomy extending class, I get a PHP error and my site wont load at all (white-screened). This isn’t super important right now as I’m leaving it in as to not deal with it…but I’m not using the extending class.

    2. Oops… didn’t check custom post types after getting rid of that line. It seems I need that line to get the meta boxes to print out. Catch-22… what do I do here? Conditional to check if it’s a custom post type or not?

    3. Hi Jaace,

      This line: $my_box = new RW_Meta_Box_Taxonomy($meta_box);
      will register a variable, which handles all actions of meta box. So if you
      comment out this line, the script won’t work properly, of course.

      If you don’t want to use the extending class, use this instead of the above

      $my_box = new RW_Meta_Box($meta_box);

      and not that you MUST not use the ‘taxonomy’ field type.

      By the way, I would like to see your edited meta-box-usage.php. You can post
      it at and put url here. It can make me clearer about what
      you’ve done.

    4. Hi Rilwis:

      I will post my code for you to see… but first I want to let you know that I’ve narrowed it down even further. I went to wp_postmeta and just got rid of all my custom field data. After doing this, posts, pages, custom post types all saved normally.

      Now, when I went to a custom post type to fill out a meta box (thus creating an entry in wp_postmeta and creating that new meta field) it worked but when I went back to Posts or Pages, they reverted to doing the same error as before upon save.

      It seems as though I need to have at least one custom meta field for each post type (custom types, pages and posts) in order for each one to work. Seems strange but that’s what it looks like to me right now. This wasn’t happening when I had left the original code in place that gave each type it’s own meta fields.

      Here is the pastbin URL:
      NOTE that I have bypassed the extending class entirely. This was still happening before when I was using the extending class. I have no use for it so I wanted to just call the normal meta box class.

      Let me know what you find 🙂 and thanks for taking a look at this!

    5. Me again (sorry for all the updates):

      I added this to my meta-box-usage.php file:
      $meta_boxes[] = array(
      ‘id’ => ‘page_post_info’,
      ‘title’ => ”,
      ‘pages’ => array(‘post’, ‘page’),

      ‘fields’ => array(
      ‘name’ => ‘Placeholder’,
      ‘id’ => $prefix . ‘def_placholder’,
      ‘type’ => ‘text’,

      Now my pages and posts save (even if no data is put in the meta box field). If I go in and comment out the fields array, it will have the same “Are you sure” error as I was getting earlier.

      It definitely seems to me like if any post type is not addressed in this code for meta-boxes, they will have this error upon saving. It seems like the function expects each post type to be addressed and if it isn’t it conflicts with something in WordPress’ core.

    6. Thank you very much Jaace, I’ve just tried all you did and seen the problem, too. However, I know where is it, and will fix it right now.

    7. Hi Jaace, please try this new class file Just overwrite it to old meta-box.php file. And let me if you find any problem.

      PS: It’s the testing new version, and I hope getting feedbacks before releasing it 🙂

    8. Hi Rilwis,

      I will put this onto my development server tomorrow and report back to let you know how it goes.

      Thank again for looking into this and also developing these functions!

    9. I’ve been having the same problem as Jaace with the updating of posts and leading to that error screen. I’ve used the new file that you provided, and it seems like it fixed that problem. I haven’t tested it extensively, but looks like it’s working good.

      Thanks for the script and the fix!

    10. Confirming, along with Dan Le, that I am able to save post types without that error screen popping up, when they don’t have any custom meta boxes defined for them.

      Thanks again Rilwis!

  16. Hi, thanks for the excellent meta box class! I’ve used it before and it worked great, but now when I’m trying to use it again in a fresh theme I get the following notice when creating a new page/custom post type:

    Notice: Undefined index: post_type in /path/to/theme/includes/meta-box.php on line 439

    And the data does not get saved. I’ve included the meta-box.php and meta-box-usage.php. Any clues on what could be causing this problem?

    1. Found the issue: The data does not get saved if both the title and the default text editor is empty.

      Seems like a bug or feature in WordPress, or something. Or am I doing something totally wrong?


      Btw. does anyone have some tips on how to add meta data to the images(title, description etc.)? That would be awsome!

  17. Rilwis, I’ve needed a few extras to your script and I’ve added multiple option to the text inputs and a global check if the add_action functions already fired by another RW_Meta_Box object. It’s not much… i can either send you an archive or a diff. My alts are based on 3.0.1. The only problem that I must figure out is why get_post_meta() returns unordered list and how can it be sorted.

    1. Hi Rilwis, I’ve also added an extra feature to your script. I wanted to be able to mark a particular image to be used as a Logo by setting it as the post thumbnail. So I’ve added an extra AJAX call in there and there’s another link that appears beside each image that’s uploaded which lets you mark it as a thumbnail or in my use case ‘Set as Logo’. Once set the link is hidden from all images and an ‘Unset as Logo’ link appears beside that image.

      I’ll email you a copy of my modified version of the 3.0.1 file. I’ve added an extra DIV wrapper around the links below the images (the links were overlapping the images otherwise) and I’ve also given the links the ‘secondary-button’ WordPress class so that they appear like the standard light grey button.

      Thanks a lot for the great script, it has worked out great for what I needed to build!

  18. Hi Rilwis,
    Many, many thanks for this awesome script – really impressive and very helpful!
    I just have a small question that I was wondering if you, or anyone else out there, might be able to help with, which is: how to set the images that the user can upload to be a certain size?
    I’m currently running the script as a custom meta box to allow users to upload their images for a custom image rotator. The users will probably be uploading images of any old size and I would like to resize all uploaded images for this custom post to pre-set dimensions…
    Is this possible? Any ideas how I would go about doing it?
    Many thanks in advance,

    1. Hi Animalraw,

      I’m glad that the script helps you in developing :).

      Regarding image sizes, because the script uses built-in functions for image uploading, the sizes are exactly “thumbnail sizes”. That means you can register more sizes using the function add_image_size().

      And to show images in the front-end, use this code

  19. I just want to say thank you so much for this — I know it will be fueling a lot of future projects, and this is the first code download / tutorial that was clear enough for me – a beginner – to understand and learn better programming skills from. THANKS!

    1. Hi Anders Larsson. I’ve just updated script that allow user to style fields with “style” attribute. Please see it.

  20. Thank you so much for this! Its been a life-saver. I’m having some issues with having multiple meta boxes on the same custom post type. Specifically the add more… button. When I have an image input in several different meta boxes, and try to add another file, it adds two inputs instead of only one. Any ideas? Any help would be greatly appreciated

  21. In your taxonomy example you use a function called ‘checked’ that I’m not familiar with. Would you happen to have any documentation?

  22. Amazing piece of code… really !!! I have a little question, it’s possible to create a sigle “type” for one image only? without “Add more images”?

    Best regards and thank you for your time

    1. Hi,

      A fastest way to do that is create an extending class based on this class. In this new class, you can overwrite the code for showing images (just remove the “Add more images” link) and its corresponding javascript.

    2. If somebody has a solution to this please pass it along. Having trouble getting the image fields to save 🙁

    1. Maybe you’re right. I have the same problem on my localhost. I’ll figure out
      why. Thanks for report.

    2. The screen options and help are working for me on my localhost – but – the time slider isn’t.

      WP 3.1 + XAMPP

      I haven’t had an opportunity to test it out on a live server yet.

    3. Or rather, we didn’t “Fix” it but I determined that it was a jQuery conflict with this script and the WordPress core.

      Basically you cannot use the Color Picker field type if you want to have your contextual menus work (Help and Screen Options). Simply get rid of it or comment it out since the default meta-box-usage.php uses the color picker field type.

    4. Looks like I spoke too soon.

      Apparently everything works fine on pages but on posts the “Screen Options”, “Help” and expanding and closing meta boxes doesn’t work.

      I checked out the previous comment but I’m not sure where in the code you were referencing, do you have an approx line number?

    5. I commented out line 183-187 (the “your favorite color” field that uses the color picker). This was causing a JavaScript error for me and when I removed it, the Contextual boxes (screen and help) opened and closed normally.

      I never tried expanding/collapsing the actual meta box fields though.

  23. Hi Rilwis! Me again, this time with one more bug and a question for a feature:

    1) I’m thinking that this is similar to the last bug I reported with the Page or Post (or custom pos type) going to that error screen upon creation or publish. It saved but always popped that error up.

    I just noticed that with Quick Edit, whenever I click Update, a -1 appears under the Cancel button and the box doesn’t close. The info I change saves but requires me to physically reload the page or go away and come back in order to see it reflected or close the quick edit box. This isn’t a huge error but a bit annoying.

    2) Feature request…sort of: I want to allow a user to re-order images that are uploaded. I know that your script uses the Core WordPress Media library even though it’s in the meta box, which is great, because images can then be reordered through the standard WordPress gallery on a page or post as usual.

    What I’m trying to do is hide the actual text edit box and keep either the original buttons for the Upload/Insert Media, Images OR just add a custom link within the meta box that links to this same place, when an image or just regular file upload field type is present (an even more elegant solution in my opinion). A user could then go the modal window, select the gallery tab and re-order images right there instead of needing to keep the Text Editor in place, even if it shouldn’t be used at all except for the gallery functionality. Is there any easy way for me to do this? I realize that it’s not JUST a link to the modal window…probably.

    1. Hi Jaace,

      Actually, I’ve done the #2 after revisiting the code from Kai. I just want to fix some bugs that you and others have reported before release the next version.

      I’ll consider about the #1 🙂 Thank you for reporting 🙂

    2. Hi, any news about the bug in the Quick Edit panel (-1 appears and the panel doesn’t close)?

      I disagree that it’s only a bit annoying – this is a major problem, because it breaks WordPress functionality.

    3. Micha; If you go to the development page and download version 3.1.1, the Quick Edit issue is no longer happening.

      BTW, what WordPress functionality does this happen to break for you? I had only the issue with -1 showing up…the post actually does save but you need to reload the page. Was there something else that was happening?

      Here is the link to the newest version of the code that Rilwis has released:

    4. Jaace:

      I’m only referring to the bug with the Quick Edit panel – if a plugin, function or other modification breaks this, it’s a major issue.

      Happy to hear it’s been sorted out, but I’ve even looked for alternatives in the last few hours because of this. Found

      Worth checking out.

    5. Just trying to understand what it broke exactly? The -1 popping up didnt break anything for me, just showed a -1 and didn’t refresh the page. So I suppose page refresh was broken…is that what you mean?

      Anyway, it’s working in version 3.1…you should check it out.

    6. Hi Rilwis! I just downloaded the newest version but I don’t see anything different. It also seems that when you try to specify more than one image or file (via the ‘add more image’ link) and then upload, they don’t appear there in the meta box. They only appear there when you do these one at a time.

      Is there a development version of the script you’re referring to with these fixes? The date-time sliders are also not functioning for me.

    7. Sorry! Feel free to erase this and my other post above. I downloaded the incorrect version of the script (3.0.1 instead of 3.1 on the development page).

      The image upload script is great!

  24. Hi Rilwis,

    I’ve been following along closely with all the new posts to this thread, it’s been a great learning experience. I’m going to trouble you again, I’m afraid.

    I still can’t figure out how to use the image uploader to convert the uploaded images to custom fields instead of image attachments? I’ve tried to work the code, but I’ve failed. Is that possible or am I simply missing something?


    1. Hi Justin,

      Which version of the script are you using? I ask this because I have updated
      the script to v3.0.1. In this version, the urls of uploaded images are saved
      in custom fields. Please check it out.

    2. Works like a charm. No idea what I was doing wrong. Thanks for your work. Happy to donate.

    3. Looks like I’m having a small issue. The images are being saved in a custom field perfectly, but the trouble is that the custom field is the same for each image, and when I go to call that custom field it has no way of differentiating between images.

      A solution could be to add an additional meta field for each image upload, but that may be cumbersome.

      Any advice?

      Thanks again for your work!


  25. Is there a way to extend the save function to save taxonomies using wp_set_object_terms instead of saving them as a custom field?

  26. For starters, amazing work.

    Maybe its just me, but I really don’t understand how extending the class works or exactly what it does. Very confused here to be quite honest. Could someone provide a link to more documentation perhaps?

    I understand that it allows you to access taxonomies from what little I understand, would there be a way to modify this so it grabs a list of a certain custom post type?

    1. The extending class is just about making it available for developers to easily add in their own functionality. These files that Rilwis developed and compiled are all object-oriented, so they are easily extended…but as far as documentation…it’s really just wide-open. There isn’t an API or anything like that, besides what you see in the meta-box-usage.php file and what’s on this page.

      Of course there is the WordPress API and documentation, which is primarily what these OOP classes build upon.

    2. I understand OOP and what the chunk of code is for. I’ve never worked with extending classes though and some other coding tidbits that are new to me. I would just like a better explanation of how it works, or to have the code broken down in easy to follow chunks.

      More comments in the example would probably do the trick.

    3. Hi ashblue,

      Basically, the extending class contains all variables and methods from parent class. So it works the same as the parent class.

      But the extending class can contain more its own methods or variables, and these will do something else.

      In downloaded files, I provided an example class call “RW_Meta_Box_Taxonomy”, it has its own method for displaying taxonomies. That means this method adds a new functionality for original (parent) class.

      I also wrote some ideas of using extending class in the post content. Hope that helps you.

    4. Thank you, that makes more sense. I think I know what I’m doing wrong with some of the extended classes I wrote for making a list of a current post type.

      PS Would be awesome if there was a forum for this so people could share their custom class creations.

    5. Yeah, a form would be great. Might just be good to start a website dedicated to this plugin. Meta box scripts tend to vanish over time and get dropped. A community would probably boost people’s confidence in using it.

      Also, can I use this script in templates and plugins I sell? I don’t see any licensing associated with it anywhere.

      PS I will totally donate to you for this script if you put a PayPal link up. I’ve used it on a million projects.

    6. Of course Ashblue, you can use it in your themes, plugins or any commercial products. It’s under GPL license. I’ve just written this since v3.1 (at project page).

      Btw, there’s donate button close to the download link. You can donate me using it. Thank you for your donation 🙂

  27. How can I get custom posts “Books” appear in Select? Like you’ve done in the example with the Categories.

  28. Added support for Custom Post Types similar to Taxonomies.

    – in meta-box-usage.php, after Line 62 Added:

    // show custom post list
    function show_field_custom_post($field, $meta) {
    global $post;

    if (!is_array($meta)) $meta = (array) $meta;

    $this->show_field_begin($field, $meta);

    $options = $field[‘options’];
    $args = array( ‘post_type’ => $options[‘post_type’]);
    $customs = get_posts( $args );

    // checkbox_list
    if (‘checkbox_list’ == $options[‘type’]) {
    foreach ($customs as $custom) {
    echo “post_title'” . checked(in_array($custom->post_title, $meta), true, false) . ” /> $custom->name”;
    // select
    else {
    echo “”;

    foreach ($customs as $custom) {
    echo “post_title'” . selected(in_array($custom->post_title, $meta), true, false) . “>$custom->post_title”;
    echo “”;

    $this->show_field_end($field, $meta);

    To show the Meta:

    ‘name’ => ‘Custom Posts’,
    ‘id’ => $prefix . ‘custom’,
    ‘type’ => ‘custom_post’, // custom post
    ‘options’ => array(
    ‘post_type’ => ‘artist’, // custom post name
    ‘type’ => ‘select’, // show as ‘select’ or ‘checkbox’
    ‘desc’ => ‘Choose One Custom Post’

    1. That’s nice, Dert. Thanks for your class.

      Actually, when I named the extending class “RW_Meta_Box_Taxonomy”, I meant each developer should develop his own class for something. It makes us easy to share between others without worrying about conflict.

      At user point of view, wrapping all extending methods into a class “RW_Meta_Box_Extend” is a good approach. Because they don’t need to extend the class, they need only a bundled class :D. So, a single class for everything is ok.

    2. Couldn’t figure out object oriented programming for this (a little different from my Visual Basic class with OOP). Gave in and watched a video series to refresh my memory. Figured out how to create a class extension with Ervald’s code and this video series. Highly recommended for those struggling with OOP.

  29. This is a nice article..
    Its very easy to understand ..
    And this article is using to learn something about it..

    c#,, php tutorial

    Thanks a lot..!

  30. Hi Rilwis, i wanted to share a video of the changes i did to your code, some styling and a little of jQuery, i’m still working on this so once is ready i want to share it if someone is interested.

    Now one question, i’m trying to find the way to rearrange the uploaded images, i was looking in google and found this tutorial do you think this tutorial is a good start to accomplish this?

    1. Your slider is very cool. I’d love if you share it here :).

      By the way, you should update my script to latest version (3.1 at the moment) at the project page. It has reorder uploaded images feature.

    2. Ok, i’ve updated the script to the latest version, and i’m trying to understand how it works, i’ve created a class for checkboxes and is working correctly, but if i add $this->check_field_select(); i get this error
      ( Call to undefined method RW_Meta_Box_Taxonomy::check_field_select())

      Now, i want to create a new function to add some scripts and css files, but i don’t want to check if some field is used i just need the function like this:

      function my_function(){
      // do stuff
      add_action(‘admin_head’, ‘my_function’);

      But this way, wp display an error in the add_action line…

      i read the documentation in the project page but still can’t figure it out, any tip is appreciated

    3. Oh, the method check_field_select() was not implemented, so you can write it yourself.

      Add to add some custom functions in the class, use the following:

      class YOUR_CLASS_NAME extends RW_Meta_Box {
      function __construct($meta_box) {
      add_action(‘admin_head’, array(&$this, ‘my_function’);
      function my_function() {
      // do whatever

  31. Hi again, just one question, currently is not possible to display the taxonomy of a custom post type, am i right?

    1. IMHO, I think the extending class works with custom taxonomy of a custom
      post type. I haven’t tested it yet. Don’t they appear in your site?

    2. For the insert button, i notice that the insert in to post button, is not displayed only if the editor is disable for that custom post type.

    3. You’re right. I’ve just checked the script and found that I haven’t enqueued scripts for uploader and tinymce. Will fix it in next version. Thanks for report.

    4. Rilwis, do you have any further info on the ability to allow the admin user to use the standard WordPress Media Upload buttons to allow for an image to be integrated into the content of the “WYSIWYG” WP Editor (i.e. the use of the standard WP “Insert into post” button)?

      We are writing an extension class to your excellent Meta Box script, and are working on this issue WP Editor/insert image into post issue at the moment.
      You mentioned enqueing the scripts for the uploader and tinymce and I was wondering whether you had some code snippets we could use to fix this, or perhaps some other links to sites which address this issue?

      I am currently going through this post – – to see if we can get some more info.


  32. Hi,

    i had a problem with using multiple fields of type “time”. The timepicker didn’t work. In meta-box.php i changed line 347 from

    echo “$(‘#$id’).timepicker({showSecond: true, timeFormat: ‘$format’})”;


    echo “$(‘#$id’).timepicker({showSecond: true, timeFormat: ‘$format’});”;

    to fix it (have a look at the additional ‘;’). So this worked for me. Maybe it’s interesting for the next update.

    Greetings from Cologne

  33. As a heads up, it seems that the textarea attribute is not outputting an ID. Might just be me, but I don’t seem to be doing anything wrong.

  34. Is it at all possible to add a meta-box to a certain post type, like a page…but only those pages of a specific ID or name, etc?

    My issue is that I don’t want to create a unique post type for a few pages that need a special meta-box field that shouldn’t be available on all other pages.

  35. In case you don’t know this bug:
    – I added a new WYSIWYG metabox for posts.
    – If I upload an image in the default content editor and click the ‘insert into post’ button the image is inserted in the WYSIWYG editor and not in the default one.

    Another issue I found is the date picker. After picking a date the picker returns 23ate for the 23th of April. Is it possible to return something like this: 23-04-2011?

    1. Hi Anne,

      You can always define the format of date picker. Please look at my comment for date format in meta-box-usage.php.

  36. Here a question!

    With the category select taxonomy

    ‘name’ => ‘Categories’,
    ‘id’ => $prefix . ‘cats’,
    ‘type’ => ‘taxonomy’,
    ‘options’ => array(
    ‘taxonomy’ => ‘category’,
    ‘type’ => ‘select’,
    ‘args’ => array()
    ‘desc’ => ‘Choose One Category’

    Let’s say I want to have a list of categories plus an additional option for “no category selected”

    Any tips on how to do that?

    1. Using the taxonomy class extension that is built into this script, just add a line after the for each statement that outputs your options. That should do the trick.

  37. Hi everyone,

    First off thanks very much to Rilwis and all you groovy people in this new community for making such a great piece of code!!

    OK… so I found it very straightforward to get up and running with the code (although I found that it only worked with includes when meta-box.php and meta-box-usage.php were in the theme folder next to the functions.php file.

    Anyway…. my question is quite complex, because we are trying to do something quite interesting with WP – so apologies in advance:

    I am developing an interesting WP CMS plugin which sits on top of WP (3.1) and Magic Fields (1.5.4). Essentially I am using Magic Fields (MF) to create new, customised WP CMS areas with page specific custom field structure for data collection, using MF generated input elements such as textfields, textareas, dates, files, etc…
    The reason we use MF at this stage, is to reduce the development time needed to specify and create the new WP admin menus and for the creation of the “CMS” groups and fields.

    The WP site administrator, uses MF to define these groups and custom fields which are then used by other site WP “users” to record detailed and specific CMS content. This decision to use MF for this was also taken to reduce the demands of support and maintenance when WP gets updated in the future.

    We have a series of very important reasons to then create new non-MF (or standard looking WP) admin environments where we re-create the already assigned MF CMS (write panels/custom field) data structures into a new, dynamic AJAX based WP admin environments using the Meta Box Script V3.1 to interpret and render the MF “CMS” setup (hence why I am here now).

    We do this because we want to radically change the way that the WP admin works and looks – essentially turning it into a Killer CMS, which is incredibly flexible, powerful and customisable for beautiful, insanely usable interfaces and applications.

    For example we may create a WP admin menu section (using MF’s) called Events, which allows multiple WP posts to be created, storing highly customised event CMS data via the MF groups and custom fields – such as event name, participants, dates etc…
    We then switch off all the WP admin interface, and re-create the new CMS menu and subsequent WP-driven CMS editing areas using a mixture of PHP, AJAX and CSS for much more control and power than MF can offer.

    We use a standard PHP/MySQL combination to re-create the new CMS menu, and then AJAX to show the WP posts that have been created for each CMS option. When a post is chosen by a user, then we use AJAX to display the reworked WP editing environment based on the custom fields set out in MF. It is this recreation of the editing environment that I want to use Meta Box Script V3.1 for.

    My main question is how do you create meta-box’s using the v3.1 script in PHP files which have been called by AJAX in custom created plugin pages (rather than the usual WP generated edit/new post pages)?

    Meta Box Script V3.1 works great in normal WP post/page pages but I suspect it has something to do with add_meta_box $page attribute because the PHP file attempting to generate the meta box’s has been called by AJAX so no longer effectively shares the same add_meta_box $page attribute that was initially set before the AJAX called this PHP file.

    Naturally I have tried setting the $page attribute within the meta-box array definition to the slug defined in the add_menu command but to no avail. I have also tried trawling the Net to find someone with the same issue but have drawn a blank, so I was hoping that some of you coding geniuses out there could share some love?

    OK… so if anybody actually understands my obscure ramblings, then I would very much appreciate any advice or thoughts.

    Apologies again for the convoluted description but it is a bit difficult to explain, and I have been sitting at my computer for far too many hours now :o)

    My thanks in advance.

    1. OK.. so I worked it out. It requires the use of WP’s wp_ajax… action command which then allows you to make the meta_box request using the callback function specified.

      Interestingly enough, in my search for an answer I have worked out a far more elegant and simple solution to achieve what we are after – which is cool!

  38. First of all: This code is just wonderful! Thanks for all of your efforts!
    Next, I’d like to pay your attention to file delete bug for the sake of a further development.
    For the testing purpose I’ve created 3 meta boxes each of which allows a file to be uploaded. By trying to delete any of them (click on Delete button next to file name), there’s an alert javascript window popping up 3 times which actually requires triple confirmation. By increasing the number of meta boxes (along with file upload fields) the number of js alert windows is also increased. It looks like alert box gets popped out for each and every uploaded file, regardless the fact only one needs to be deleted. Any ideas why it happens?

    1. Bump on this for the delete functionality. Built a large scale portfolio with multiple uploads, similar difficulties. Would be nice if we had a roadmap for bug fixes and what nots.

  39. The image order code is not working in 3.1

    You drag them to the custom order and nothing happens front end, they remain in the order they are uploaded in?

    Does the code to display the images need an ‘order by’ in it?

    Anyone help out with the custom order? 🙁

  40. !!Bug Alert!!

    The scripts are turning off part of the JS in the admin when using custom post types.

    The collapsing boxes and moving boxes around in the admin dont work with custom post types?

    Any idea how i can turn it back on or what is effecting it?

    1. Probably because of the Color Picker. My comment earlier details this problem and how to get around it, which is primarily to not use the color picker.

  41. How do you get the url of an uploaded file, example a pdf you’ve uploaded?

    The first method just prints the ID of the file, the second prints the link behind its name.

    Anyway just to get the link printed as a url with the www. at the start?

  42. There is a BUG in the image uploader part of things.

    You always have to upload the image for it to appear on the page, you cannot pick an already uploaded image from the media library and attach it to a page.

    If you try it doesn’t show anything front of the site.

  43. When using the image uploader custom field, the images that are being displayed in the Admin are being loaded as full size and scaled down to a thumbnail, which add a ton of extra data loading.

    $src = wp_get_attachment_image_src($att, ‘full’);

    This should be changed to just load the image thumbnails:

    $src = wp_get_attachment_image_src($att, ‘thumbnail’);

    There’s a couple other minor tweaks I made, but this was causing a major lag on the admin side.

    But, overall this is an excellent script and I am extremely happy with it! Thanks for the great work, and for sharing it with all of us!

  44. Thanks so much for this code. It saved me loads of time!

    I just have one small question, would it be possible to add an ID to the form fields? For example I have a text area that I need to target with jquery so I would need to give it an ID. Is this possible please?


  45. hello there! – would it be possible to add fields dynamically? ie. like to display a reduced price – just when you need it. given the jquery for this, but i know this would require at least a unique id. just how would i extend the $meta_boxes array for a given posttype?

    apart from my question, awesome script you put out there! thanks!

  46. I’m using this script for my themes on ThemeForest (thank you so much btw, really a life/time saver), but I’m using the image uploader and I notice when I select a few images and keep adding more, sometimes it will like push the “Choose File” button higher up through the images. Like it doesn’t keep the “Choose File” button after all the images that are uploaded. It will always be listed under the first image uploaded.

    Here’s a screenshot:

    Is this easy to fix this?

  47. Not sure whether it’s a bug or else…
    Whenever 0 (zero) is entered to meta-box text input field, it simply disappears after Post save. Anybody knows why it is not allowed to enter and save zero with meta-box? That’s kinda silly!

  48. Really usefull script! I can’t find the way to add metabox just to a specific postID or page template. The “pages” array support only (page,post, custom_type)? There is no way? tnx

  49. Shame on me, didn’t see this post.

    Thanks to Jez who pointed me to version 3. Looks great and I like the way i could extend this class with my own fields.
    Downloading this one and looking forward to contribute new ideas.

  50. You might want to update the example for the checkbox list:

    // and use: if (in_array($checkbox_list[‘reading’]) {// do stuff}


    // and use: if (in_array(“reading”, $checkbox_list)) { echo ‘do stuff’;}

    Or else you will get the warning : Wrong parameter count for in_array()

    Best regards,


    Thanks for this awesome work!

  51. @rilwis:disqus  How do you add the custom meta boxes on a page or a post (not the wordpress editor but on the frontend) and save the value entered by the user? I have added couple of metaboxes to a post type which a user can input from the front end but having no luck saving it. I can save the values when entered on the WP editor screen.
    Thanks a lot, this code is just heavenly!!

    1.  Hi tejas, actually I haven’t created meta box for front-end pages in WordPress. This work is not really easy as it comes with form design and submission. There are plenty of form plugin that comes with built-in fields type that you might want to check (like Contact form 7 or Gravity)

  52. hi,
    i need a little help, take a look at my code.

    function hiro_keyword() {
    $keyword = get_post_meta(get_the_ID(), ‘hiro_keyword’, true);
    echo ” . “n”;

    add_action( ‘wp_head’, hiro_keyword’ );

    all i want to do is, to not show this in when the data is not inserted, i tried to do it with if else statement but failed, can you please help?

  53. and one more question, how do i select the options for the radio multifield, im kind of confused, for e.g.

                ‘name’ => ‘Robots Meta‘,           
                ‘desc’ => ”,                           
                ‘id’ => $prefix . ‘robot’,               
                ‘type’ => ‘radio’,                       
                ‘options’ => array(                       
                    ‘indexfollow’ => ‘index, follow’,
                    ‘indexnollow’ => ‘index, nofollow’,
                    ‘noindexfollow’ => ‘noindex, follow’,
                    ‘noindexnofollow’ => ‘noindex, nofollow’

    how do i show the options in the template?

  54.  So glad you updated all of this!

    I am using this version now, and I have changed nothing in the code you have provided, however when I use a select or checkbox_list so you can select multiple options… nothing gets saved. Even Radio wasn’t working when I would check a new box. Am I missing something?

  55.  Actually just noticed that none of the fields are saving for me now… Still using the code you have provided already…

    1.  Okay looks like I figured this out. The files need to be placed top level in your theme folder. I would prefer to have them in their own folders for organization, but I can live with it!

  56. I call it the Advanced Meta Box Class and I’ve added a lot of nice little features to it.  I tried to document them all in the document, but my features include:
    – Changed most of the functions to include an argument for the post_id.  By not assuming the post id is the current page, you can reuse the functions to be used to pull meta from other posts.  I have another class I’m working on that does just that and uses other post types as attachments like WordPress does.
    – Added a ‘get_meta_{$type}’ system, similar to how you had ‘show_field_{$type}’ functions.  This allows you to do a number of things: pre-format metadata before you display it or pull data from other sources other than the custom fields/ postmeta table.  
    – Taxonomy type.  Extended from your version.  It uses a custom ‘get_meta_taxonomy’ to pull terms from the taxonomy system.  It also uses jQuery to support hierarchical taxonomies.
    –  Rehauled the image system.  Now you don’t need to save the images as metadata: I created a ‘get_meta_images’ function that does a query of all the attached image ids and returns that as the meta.  I also redid the jQuery you did to refresh the images in the metabox once you upload them.  You can also now upload multiple images at the same time and have them be refreshed no problem.
    – Separated as much of the scripting and styling as I could in separate .js and .css files.  Hope you don’t mind.  The parts which were more php generated that had to do with the image system I left in the class.
    – Added ‘get_field_name’ and ‘get_field_id’ functions.  Like the first change, I did this to add support formore flexibility.  You could change the way you set the name or id attributes of your fields so you could support more complex meta boxes, like ones that pull data from multiple other posts of different post types.  
    – Parent type allows you to set the post_parent of a post, creating a hierarchical structure across multiple post types.  For example, you would implement it like so:
                            ‘name’ => ‘Series: ‘,
                            ‘desc’ =>’Select a series’,
                            ‘id’ => ‘veda_content_series’,
                            ‘type’ => ‘parent’,

    This is from some code I’m working on.  The parent_type is the custom post type of the parent you want.  It then gives you a select field that lets you pick from a list of all the posts of that type.  The one you pick gets stored in the post’s post_parent field in the wp_posts table automatically.  Cool part is that WordPress saves it automatically because the field’s name is post_parent.  No save function required.

    Phew.  I hope you enjoy the changes I’ve made and I hope it helps someone’s project.  Let me know if you have questions.

    1. That’s awesome Manny. I love your enhancements and will put a reference in the project page.

    2. How do you add this and implement with the current script? I’ve included with the other bits but no change…?

    3. @7fd971ed32fdc35daebc9fc5616cd4c3:disqus You implement like so:
      new Advanced_Meta_Box($metabox);

      $metabox being the array of options

    4. Hi Manny. How do I display the date? All I get is “Jan/1/1970” no matter what date I enter, using this code to display:

      ID, ‘event_date’, true);
      $new_format_birthdate = date(‘M/j/Y’,strtotime($birthdate));

    5. take out strotime. 

      $birthdate = get_post_meta( $post->ID, ‘event_date’, true);
      $new_format_birthdate = date(‘M/j/Y’,$birthdate);

      That should work

    6. how do I implement this?
      With Rilwis’s files, I used include “(TEMPLATEPATH. ‘/meta-box.php’); include (TEMPLATEPATH. ‘/meta-box-usage.php’);” in the functions.php from my theme.
      If I do the same with you files, class-advanced-meta-box.php and advanced-meta-box-usage.php, everythink brakes down.
      So, how can I do this the right way?

  57. Hi there,
    i´m testing your “Screenshots” example but after uploading nothing shows up under the “uploaded images” text. is there any problem? 

  58. How could I add a tinyMCe toggle button to switch between visual and html views?

    1. Here is a link to the code I added –

      and here is a link to it implemented –

      The only problem with this solution is that it toggles the HTML buttons on the main content uploader in the admin panel (you will see once implemented) and rewrites the html or visual cookie.

      Let me know if you find an alternative solution without the problems.

    2. Hi Matthew,

      Any chance you can you post the code again, as Disqus comment system seems to have stripped it out?


    3. Hi Matthew,

      Thanks very much for this. I have integrated your code and can see the buttons but they appear to have no functionality. Did you enqueue any scripts to get basic functionality (albeit with issues) working?

    4. Working now and integrated into our new class. We will keep working on the issue too. I will let you know how we get on. Thanks again :o)

    5. Has anyone got the toggle visual HTML tab working yet? Ive tried all the code mentioned here but no dice. Im using WP 3.2.1

  59. Hi

    First off thanks to Rilwis and all for making this cool & very useful piece of code…

    I use Dert code in extension from pastebin.

    I just have a few questions about listing usage for custom post type with checkbox list.

    here is the code I use in the meta-box-usage.php :

    ‘name’ => ‘Disks ‘,

    ‘desc’ => ‘Select Disks.’,

    ‘id’ => $prefix . ‘associated_disques’,

    ‘type’ => ‘custom_post’,

    ‘options’ => array(

    ‘type’ => ‘checkbox_list’,

    ‘args’ => array(          

    ‘post_type’ => ‘disques’,

    ‘order’ => ‘ASC’,

    ‘orderby’     => ‘title’,

    ‘posts_per_page’ => 100


    ‘multiple’ => true

    This works great but get as meta values the name of post.

    Is there a way to get as meta values the slug of post or directly the ID?

    by keeping listing in meta box with the name of post.

    (getting the name of post as meta values could be problematic in case of homonym or special caracter…) 

    Hope it’s clear…

    thanks all

    1. Because that code uses post title as the value. Look at the line 66 and 74, all you need to do is changing $custom->post_title to $custom->ID

    2. Thanks for your answer.
      That’s what I have done and it works great.
      (I found the solution just after posting my comment).
      However thanks for your support.
      This is great stuff.

  60. Extremely useful class. Thanks a lot !! This makes everything a lot easier. I understand this is still improving and was wondering how to add images using the wysiwyg type field ? I’ve tried  the wp code function “the_editor()” which displays the adequate buttons but the  “media_upload” won’t let do that. The only link available is the “use as feature image”. Did anyone been there ?

  61. I have a big problem. I need to use the quick edit feature a lot, but it dosnt save properly for ‘Pages’ and ‘Custom Post Types’ only ‘Posts’ the quick edit feature works for.

    The problem is this line of code…

    foreach ($meta_boxes as $meta_box) { $my_box = new RW_Meta_Box_Taxonomy($meta_box);}

    How can this be fixed?

  62. Hello,

    First of all, thanks a lot to everyone and especially Rilwis for keep up the updates and working on the code – it’s amazing 🙂

    I’m having a bit of trouble with file field, hoping someone could help me.

    I’ve defined my meta box with a file field. After I’ve chosen a file and updated/published a Custom Post Type post the file field displays “No file chosen”. I’ve tried both versions of code 3.0.1 and 3.2. I have both meta box files in the “include” directory in my theme, but I also tried just uploading them into main theme folder.

    None of this seem to work and after saving a file, it still says “No file chosen”. I’ve check the db and there is no meta_value with the file field id.

    I use WP 3.0.1
    I would really appreciate if anyone could help me out with this!!

    Many thanks,

    1. I’ve updated the WordPress to 3.1.3 and the file upload still doesn’t work :S
      I would really appreciate if someone could help me!


    2. Please, can someone help me with this? I’ve no idea why the file upload doesn’t work 🙁 Does it work for everyone else?


    3. I think I figured it out. It won’t save files because the “upload” folder didn’t have permissions to write. I had to add debuging statements directly into the main file meta-box-3.2.class.php

      I think it would be a huge improvement if errors like that (no permission to write to the “upload” folder) would be displayed near the “Upload files” field – so it’s clear and straight forward.

      Thanks for the great code, Rilwis 🙂

  63. Hello,

    Has anyone extended the delete functionality of attached files? Is it possible to have a confirmation popup of delete or cancel before the actual delete of files from the post?


  64. Hey, with debug mode enabled i see a notice when i click on “Add new post” or “page” or “custom post type”:  Notice: Undefined index: post_type …. meta-box.php on line 121.

  65. Really love this new version. 

    I am trying to create a new field type. I want it to be a field type that has three input boxes along with an “Add” button. Example: Item Name: Item Price: Item Description:.

    The “Add” button would work like the “Add more images” link that you have working with the Image field type. 

    This would allow the End User to keep adding meta boxes for how ever many items they need. That way I don’t have to limit them to like 5 or 10 items.

    The primary use for this right now would be for a restaurant custom post type. Allowing them to keep adding menu items. So then I can pull each meta box values through separately on the front end.

    Any thoughts on how this could work?

  66. Do the image import check boxes always take a while to appear for everyone else?

    Sometimes its takes a while for them to appear and i have to move mouse around a bit till they do?

    Anyway of quickening them up a little?

    Great script though 🙂

  67. First of all thanks and congratulations for that awseome script! It really rocks!! 

    I’m just guessing if it also can be used to attach, for example, an image uploader to a custom page (frontend). 

    Anyone have tryied that?

    Thanks in advance! 🙂

  68. I love your script! It makes the whole process so much easier, especially for non-programmers. Alas, I have an issue. When I create a meta box, the output in my theme does not render HTML code properly. It’s showing as text instead of, for example, a link.

    Here is the link to the code I’m using in the meta-box-usage.php file:

    And I’m using the example you give for displaying the custom meta box content in my theme:

    1. And the code I’m using in my theme got eaten by the WP Post monster:

      echo get_post_meta(get_the_ID(), ‘faf_authorBio’, true);

      I am using the proper php opening and closing tags.

    2. I guess WP auto escape (encode) special HTML characters in textarea field. You can use print_r() function to show its value to confirm that, and then decode them to show the correct value.

    3. Just wanted to say I figured it out and wanted to post an example in case anyone needs it. In your template file, use the following:

      global $post;
      $field_name = get_post_meta($post->ID, ‘faf_customField’, true);
      echo html_entity_decode( $field_name );

      Of course, you put the above code within opening/closing php tags. $field_name can be anything you like and faf_customField is the name you’re using for your meta box.

  69. Hi Rilwis.. is there a way that we can assign meta boxes on a single page.. so the meta box only appear on a single edit page.. thanks

  70. Hi,

    The metabox script is great. I’ve used it on a couple of projects and it totally kicks arse. However, I’m using the latest version on a WordPress 3.2.1 installation and the image uploader doesn’t work. After I select an image, when I return to the post edit screen I get a broken image and if i click the delete button it tells me I don’t have permission to delete the file (I’m signed in as administrator).

    Any ideas what’s going wrong and how to fix it?


  71. Hello,

    I’m using v3.2 of the metabox script. I needed to change the presentation of the metabox so it doesn’t display metabox’s fields in the table and would not output the table markup. Such metabox would only have a single wysiwyg field.

    I have added a new setting called ‘table_less_markup’ to the metabox as following:

    $meta_boxes[] = array(
    ‘id’ => ‘business-excerpt’, // meta box id, unique per meta box
    ‘title’ => ‘Business Excerpt’, // meta box title
    ‘pages’ => array(‘business’), // post types, accept custom post types as well, default is array(‘post’); optional
    ‘context’ => ‘normal’, // where the meta box appear: normal (default), advanced, side; optional
    ‘priority’ => ‘high’, // order of meta box: high (default), low; optional
    ‘table_less_markup’ => true,

    ‘fields’ => array( // list of meta fields
    ‘id’ => $prefix . ‘business_excerpt’,
    ‘type’ => ‘wysiwyg’

    I have also modified the following methods to check the new setting and to add table markup correctly:
    // Callback function to show fields in meta box
    // OVERWRITE – do not output table markup if specified
    function show() {
    global $post;
    $no_table = $this->_meta_box[‘table_less_markup’];

    wp_nonce_field(basename(__FILE__), ‘rw_meta_box_nonce’);
    echo $no_table ? ” : ”;

    foreach ($this->_fields as $field) {
    $meta = get_post_meta($post->ID, $field[‘id’], !$field[‘multiple’]);
    $meta = ($meta !== ”) ? $meta : $field[‘std’];

    $meta = is_array($meta) ? array_map(‘esc_attr’, $meta) : esc_attr($meta);

    echo $no_table ? ” : ”;
    // call separated methods for displaying each type of field
    call_user_func(array(&$this, ‘show_field_’ . $field[‘type’]), $field, $meta);
    echo $no_table ? ” : ”;
    echo $no_table ? ” : ”;

    // Overwrite the show begin and end function to suppress table markup
    function show_field_begin($field, $meta) {
    $no_table = $this->_meta_box[‘table_less_markup’];

    echo ”;
    echo “{$field[‘name’]}”;

    function show_field_end($field, $meta) {
    $no_table = $this->_meta_box[‘table_less_markup’];

    echo ”;
    echo “{$field[‘desc’]}”;

    This works correctly – the table markup doesn’t appear and it seems like all the nonce and other wysiwyg markup are coming through correctly.

    However, when I’m trying to save a custom post type with such metabox I get “Are you sure you want to do this?” message with the link “Please try again”.

    Would you happen to know what it might be?? I’ve checked the HTML markup and it’s only table markup doesn’t come through – I don’t think that saving a field relies on that… No idea what’s going wrong 🙁

    I would really appreciate your help!
    Many thanks,

    1. This might come from the nonce. Please check that carefully. Ideally, it wouldn’t be a problem if you change only the HTML markup of the fields.

    2. Thank you Rilwis for the quick reply!

      I’ve checked the mark up and that’s what I get for the wysiwyg without the table markup:

      I’ve checked the nonce values in the metabox with the original table html markup and they are the same.
      Hm, this is baffling… as I understand that should work too?

      Would really appreciate any help 🙂

  72. I need to achieve some level of knowledge for PHP as I think some of this stuff is a bit over my head. I can’t get the values to be echo’ed, have little to no idea what goes where. Anyway, great stuff, I will definitely save this, as the others were even worse (to get Metaboxes working).

  73. Great class, needed some knowledge of PHP to get it functioning, but this is great. 🙂

    (Would of been nice to have an instalation.txt plus a very simple example)


  74. Hi there and thank you for this awesome script.

    I’m a beginner in php and am struggling to display specific metaboxes on specific page templates. I’ve managed to make it show the metaboxes on one page template, but as soon I add a second metabox it displays all of them.

    Could you please give me an idea on how to display different metaboxes on different page templates?

    Cheers and thanks again for putting your work to develop such a great script.


  75. Btw, here’s my modified piece of code:

    function add() {
    $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
    $template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
    foreach ($this->_meta_box['pages'] as $page)
    if ($template_file == 'one-column-portfolio_page.php')
    add_meta_box($this->_meta_box['id'], $this->_meta_box['title'], array(&$this, 'show'), $page, $this->_meta_box['context'], $this->_meta_box['priority']);

    I have 2 metaboxes created and currently they’re being displayed on the
    “one-column-portfolio_page.php” but I want just one to be displayed on this page template and the other on another page template.


    1. Just to followup on this – should the code be added to functions.php or should the core plugin files be modified?

      Many thanks 🙂

  76. Genius!!!! After days of crawling the web and reading various half-baked suggestions about how to implement custom meta boxes, this is by far the cleanest and more straightforward framework i’ve seen.

    I don’t want to get this thread too far off-track, but something I’ve been wondering about is how to create a custom meta box field that will be populated with other posts. Specifically, I’d love to create a meta box that would list all posts of a specific post-type (ie: a custom post type called ‘Related Articles’) and allow the person to select them via a checkbox or radio button.

  77. Apologies for posting this question again, if I already did. I can’t find the original comment:

    Here’s a paste of my code;

    My client’s previous developer installed you custom field approach. I’m trying to edit.

    Basically, what I have:
    Custom Field $Value1
    Custom Field $Value2
    BUT I need a third:
    Custom Field 3 = ($Value1 + $Value2).
    Needs to be automatically updated in DB when the other values change.
    I’ll be using the third Custom Field value elsewhere to sort queries.

    Any help is greatly appreciated. I’ll be happy to donate a bit to the brew fund. Thx!

  78. thanks for this code, it has been a great help. i do have one thing that is puzzling me though….

    I have 2 meta boxes both containing different image uploads that need to be displayed in different positions on the page. I am using the code below to pull out the images but am struggling to set the thumb of that image to display rather than the full size version… does anyone have any thoughts?

    $my_meta = get_post_meta($post->ID,’rw_small_img’,TRUE);

    if (!empty($my_meta)) {
    foreach ($my_meta as $image) {
    echo “”;

  79. Hello,

    Great script! Everything I need is available. Thank you for sharing. I too have the color picker conflict issue on my end. Seen some other users also have the issue. Is there a fix for this? Would appreciate any help. I can’t comment it out because I need to use the color picker field.

    1. Yes, I too am trying to figure this out. I’m a beginner with PHP and would appreciate any direction.

      I’m using meta boxes so the user can add/change a photo and headline in the banner of each page. If it’s not possible to add the image chooser, perhaps a fallback would be to use a text box where the user can add the URL for the image?

      Thanks, Rilwis for this plugin and your helpful tutorials!

    2. @Jam:

      I agree, having the user add a URL for the image isn’t good UI design. I ended up using the metabox script only for input of the headline. For the image, I’m using the Featured Image box. This has been a grand adventure! Thanks for your suggestion. Good luck with your project!

  80. Hey everyone.

    Wow thanks to rilwis, this is an awesome piece of code!!!

    Anyways, down to business. I need to build a class that extends the built-in functionality in order to run a custom function that updates some post data when the meta box is saved.

    Basically I’ve built a metabox with the dropdown date, and I’m trying to update the post_date with that new date. I can’t figure out how to extend the class to allow me to run my custom function mf_reset_post_date(); when the metabox is saved…

    Here is what my custom function looks like:

    function cfc_reset_postdate($sm_post_id) {

    $date = get_post_meta(get_the_ID(), ‘cfc_date’, true);
    //$date = date( “y-m-d”, strtotime($date) );

    $date = DateTime::createFromFormat(‘D – M j, Y’, $date);
    $date = $date->format(‘Y-m-d’);
    $title = get_the_title($sm_post_id);

    $my_post = array();
    $my_post[‘ID’] = $sm_post_id;
    $my_post[‘post_date’] = $date;
    // Insert the post into the database
    wp_update_post( $my_post );

    Can anyone help me on this?

  81. Hi,

    First of all: The code is awesome!! Thanks a lot. Adding metaboxes is now very simple.

    But I’m having a problem with the input text fields. It seems that they don’t save html/ascii characters?
    For example, the text “You’ll find it here”, is onyl saved as “You”…

    In the textarea it’s working perfect, so it’s only the text fields.

    Or am I doing something wrong that it isn’t working? Any help is greatly appreciated! Thnx

    1. I’m having another issue in WP 3.3. With WP_Debug on, I’m getting this message:

      Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks.

      It has to do with the wp_enqueue_style and wp_enqueue_script. But I can’t figure out what the solution is…

      Anyone an idea? Because I would love to use the class in my WP 3.3 theme.

  82. Hoping someone can help me. I am using the code from before you made this a plugin and have loved it. It has made things so much easier but this morning I realized that I have a big problem. Since updating sites to the latest version of WordPress, the wysiwyg fields do not work now. I know that WordPress changed the way they are called but I can’t figure out how to fix this.

    I am going to use the plugin going forward, but I have a client site that uses over a dozen different fields from the previous version and can’t lose all of the content. Is there any way you can post the code or fix I need to do so that the wysiwyg field can work again for the previous version?

    I would be more than happy to make a donation if you can help me.


    1. Adam,

      If I remember correctly, I believe you just need to go through your included files and remove anything that the new plugin is using. There are classes and functions that are now included in the plugin, which should be removed from your register/usage/and/or definition theme files.

    2. And if it helps, I believe all of the code in question is either at the top or the bottom of the files you created in your theme folder. Something like DiffMerge can help you spot the similarities.

      Think of the files you previously created as definitions only. You define and register the meta boxes in your theme files, but the plugin handles the rest.

    3. Hey Adam! Did you fix the WYSIWYG problem?
      I am suffering from the same illness here.

      All my wysiwyg custom metaboxes are not displaying the TINY-MCE anymore in the fresh up-to-date WordPress install and I have no idea how to fix that in the Meta Box Class 3.2.2.

  83. Thank you very, very much!

    two Questions:

    1. How to change the DatePicker to my language (the names of the months)?
    2. I whould like to store Date-Time as UNIX-timestamp

    1. 1. Currently we haven’t been touched to much on date picker options, but will do it in the future.
      2. To store a date value in unix-timestamp, you can use one of these filters:
      $new = apply_filters( “rwmb_{$field[‘id’]}_value”, $new, $field, $old );

  84. Is there a way to include the existing Custom Fields “update” button that’s inline of the custom fields area? Rather than having to click “update” to the entire post, just to be able to update the custom fields that are generated using the above code.

    This would be a great addition, if it’s not already part of it. I can’t see it.

  85. Hi Rilwis. You done a NICE job, I’m really enjoying your script.
    On using it with latest wordpress version (3.3.1) and I’m getting this error when editing a metabox registered for ‘Pages’

    Warning: Cannot modify header information – headers already sent by (output started at /home/officeco/public_html/_wp/wp-content/themes/officecomm_theme/_includes/officecomm_meta_boxes.php:160) in /home/officeco/public_html/_wp/wp-includes/pluggable.php on line 866

    I don’t declare any header in script.

    Any thoughts?

    Thanks in advance 🙂

  86. THANK YOU! you rock for running through this. I needed the image upload part. Works like a charm! Greatly appreciated.

  87. Great, truly great script.
    I’ve succesfully created a gallery system using plupload, the only problem is that the featured image is recognized as one gallery image, so every article onw have at least a gallery with only one image, whereas i wanted to use the featured image by itself. How can i prevent this?
    Thanks in advance, i look forward to the progress on this script =D

    1. Hi Stefano,
      When you get the meta value for the gallery, you’ll receive an array. You can exclude the featured image from that array, using this code:

      $meta = array_diff( $meta, array( get_post_thumbnail_id() ) );

      The function get_post_thumbnail_id returns the ID of the featured image.

    2. Thank you ^^
      I have another problem with the uploaded galleries. When i create a new post and upload images, all is well (i see thumbnails and i can edit/delete images). But when i save, exit and re-enter that post, the plupload metabox “resets” itself at default status (as if no images were uploaded), but the article still have the gallery active and working, so i cannot view/edit/modify the images… there’s a solution to this? Thanks

    3. Did you click “Update” button for saving post after uploading images? Because after uploading, images are just displayed there, and we still need to “Save” post to make sure images info are saved into the custom field.

    4. Thank you, now it seeme to be working as expected (and i aven’t changed anything… oh well, it’s fine =D).
      I tried to use the code you gave me, but as i used the code you wrote in “Get uploaded images”, which have no $meta but &src instead, i tried to put it before //show image, changing $meta in $src, and the image disappeared from post with no gallery, but also from posts WITH the gallery… all images end up having no “src” defined… i have little knowledge of PHP so i don’t really know how to change your ccde to make it work…

  88. Hello! This script is really amazing!!

    Do you know if there is a way to make shortcodes work in text meta boxes?

    This works for text widgets:
    add_filter(‘widget_text’, ‘do_shortcode’);

    Maybe there is something like that for text meta boxes?

    1. In my opinion, showing shortcode content (value) is only useful if we’re in the front-end. So, we should store the shortcode in the meta box in the back-end, and show the value in the front-end.

    2. Right. But if I put the shortcode into the text meta box in the back-end, it doesnt get executed in the front-end…

    3. If you want it to execute in the front-end, you should use do_shortcode( $meta );

  89. Hey guys,

    Any idea how to fix the Tiny-MCE initializing on a WYSIWYG meta box?
    I am using the ~ meta-box-3.2.2.class.php ~ and now, in the most recent version of WP, the editor “calls” have changed and I have no clue how to fix that.

    Any tips?
    [email protected]

  90. Hello, Neat post. There is an issue with your web site in
    web explorer, might check this? IE still is the market leader
    and a huge component of other folks will leave out your excellent writing because of this

    1. I’ve checked the website in IE8 and don’t see any problem. Can you help me with a screenshot?

  91. I think this is one of the most important info for me.
    And i am glad reading your article. But want to remark on some
    general things, The site style is wonderful, the articles
    is really great : D. Good job, cheers

  92. Hi Rilwis,

    Thank you for such an amazing plugin! I love working with meta boxes but i’m having one problem: When publishing a post with meta box it won’t ‘save’. When I’m editing the post it won’t show my previous data. Anyone familiar with this / knows how to fix this?

    Again, thanks for the plugin!

    1. I’ve been modding the demo.php and added some boxes like text (for twitter link, facebook link and website link), and textarea to fill as profile information. Thanks for the quick reply!

  93. Just came across this script again after some time away and have noticed I was unable to get the taxonomy checklist to function. I thought at first that it may only be because I was using a custom post type, but tried a generic category after that and was unable to get results. I checked the custom fields section to see if it was registering at all, and noticed that it isn’t.

    Everything else I’ve used registers fine though. Just that whenever I use the taxonomy checkbox list nothing saves.

    Could it be that in the optional array I need to fill in $tax-terms?

    1. oh, its worth noting that I’m using the latest version and that its hooked into the theme and not used as a plugin. I’ve been using your metabox code since before it became a plugin and have become accustomed to use it that way. Should you find the time to assist me here, If theres any other information on the problem I can provide you with, let me know and I will provide it.


    2. And to follow that up, I’d like to also note that I’ve solved my problem by using the Helper class. Not sure how I missed that. I was using it at home, and soon as I come to the office I rewinded into using the older script version. Thats a heck of an important doc file for the > 4.1.9 version.

Comments are closed.