I love using WPAlchemy for custom meta boxes in WordPress. It’s incredibly flexible, easy to use and there is plenty of documentation available. I recently came across a small issue which I thought was probably quite a common scenario but for which there was hardly any documentation available. Here’s the situation I encountered:
I wanted a custom post type for a slider which would have a title, an image and a link ( with the potential to add more custom fields in the future). Each of these fields needed to be repeatable to that one slider post could have multiple slides. Simple enough. I added my custom post type and disabled the editor to keep the interface as simple as possible. I then setup the custom meta via WPAlchemy that gets applied to my ‘slides’ post type.
<?php add_thickbox(); ?>‘ to the custom meta template.
This seemed to do the trick at first. The modal opened and allowed me to select an image but then the modal did not close and the image URL in the field was not updated. I remembered that you could hide the editor via WPAlchemy rather than via the custom post setup, so I went back to my ‘slides’ post and enabled the editor and added
'hide_editor' => true to my meta box setup. This did the trick. The Thickbox assets are still loaded when you hide the editor in this way making the media upload fields work perfectly. Hopefully this will be helpful if you ever need to do something similar.