Support for two key features make this WordPress meta box PHP class even more attractive. With the addition of filtering and repeating fields, you have even more flexibility when using meta boxes for your themes and plugins.
My latest update to the
WPAlchemy_MetaBox class (v1.1) is a pretty good one. There are two notable features in this release:
The filtering capabilities will allow you to filter your meta boxes by template, categories, tags and post/page IDs.
I often find myself writing specific meta boxes for certain sections of a website, with this functionality, I can limit the display of the meta boxes so as not to clutter up other pages which don’t need them.
The following example will exclude all pages that use the “product” template except for a specific product page:
new WPAlchemy_MetaBox(array ( 'id' => '_custom_meta', 'title' => 'My Custom Meta', 'template' => TEMPLATEPATH . '/custom/meta.php', 'exclude_template' => array('product.php'), 'include_post_id' => 85 ));
The following filters your meta box by excluding it from several specific posts, unless those posts have the “download” tag:
new WPAlchemy_MetaBox(array ( 'id' => '_custom_meta', 'title' => 'My Custom Meta', 'template' => TEMPLATEPATH . '/custom/meta.php', 'exclude_post_id' => array(45,48,56,57,88,91,92,93) 'include_tag' => 'download' ));
With this added functionality you can create repeating fields and field groups.
A simple example would be a meta box for adding a list of links: you may have two fields, one for a title and the other for a URL (field group), using this feature of the class you can easily setup an “add new” link/button that would automatically spawn new instances of the field group you defined.
Setting up a repeating field region is pretty straight forward, read the documentation to learn more and see an example.
The documentation page has been overhauled, the class is well documented. As I make updates, I will be documenting the changes. As you begin to use the code, please let me know any issues you may have.