Custom Metaboxes and Fields for WordPress (CMB2) Now Out of Beta

The Custom Metaboxes and Fields for WordPress (CMB2) plugin is now officially out of beta and ready for public use. The tool was created to make it easy for developers to create metaboxes and forms with custom fields. Developers at WebDevStudios took over the original CMB GitHub repository from Jared Atchison, its original creator, in December of 2013.
Justin Sternberg explained why WebDevStudios chose to start contributing to the CMB2 project:
After having been burned by some issues with other custom field plugins, we determined it was best to stick with code that we had some control over. We fell in love with CMB because it was a library we could include in any of our projects and it would just work while letting us keep all of the field configuration in the code, and more importantly, in our version control system.
Due to irreconcilable shortcomings in the original CMB, WebDevStudios opted to fork the project and create a new one that wouldn’t have the same backwards compatibility requirements. If you used CMB in the past, it’s important to note that the new CMB2 project has renamed every class, function, hook, and filter in the library to avoid conflicts with the original. It’s essentially a complete re-write.
“CMB2 was built with a new mechanism to ensure it only loads the most recent version of CMB2 in your system,” Sternberg said. “This ensures that a plugin with an old bundled version will not conflict or take precedence over your up-to-date version.”
The new CMB2 is now available on WordPress.org as a plugin for easy activation when you want to use it with one of your projects. As an alternative, you can include CMB2 directly. The newly released plugin features the following:
- Create metaboxes to be used on post edit screens.
- Create forms to be used on an options pages.
- Create forms to handle user meta and display them on user profile add/edit pages.
- Flexible API that allows you to use CMB forms almost anywhere, even on the front-end
- 30+ built-in field types
- Custom API hook that allows you to create your own field types
- Numerous hooks and filters, allowing you to modify many aspects of the library (without editing it directly)
- Repeatable fields for most field types are supported, as well as repeatable field groups
The WebDevStudios team plans to maintain strict backwards compatibility moving forward, as of CMB2’s 2.0.1 release on WordPress.org. If you want to include CMB2 as part of your next project, make sure to check out the plugin’s wiki and code library for tips on how to add metaboxes, fields, and forms to WordPress themes and plugins.
10 Comments
Wow I am the first to comment! I really love these WordPress “specialised mini frameworks”. They enable me to learn and enhance without bloat.
With apologies in advance if this sounds ridiculous, it would be great if the metaboxes/fields could be exposed to the Customizer via the Customize Posts plugin.
In reference to the post about WordPress and innovation – what enables innovation is the combining of disparate technologies to generate heretofore unavailable functions and features. Accessing the output of this plugin in the Customizer would be a quantum leap for WordPress.
Report
Didn’t Bill Erickson write the first version?
Report
http://www.billerickson.net/advanced-custom-fields-frontend-dependency/
Report
I use this library quite a bit on various plugins and theme functions I build. The last time I used it, it was incredibly powerful, i’m excited to get using this new version, let’s see what we can do with it!
Report
This is a very useful library.
Report
I’ll have to give it a try, but I’m wondering how it compares with Advanced Custom Fields… anyone have experience with both?
Report
I’d say the only advantage ACF has over CMB is flexible fields: http://www.advancedcustomfields.com/resources/flexible-content/ (2:50 mark is where you see it in action).
If a project didn’t require that, I’d go with CMB every time, hands-down. The ability to define fields in code is priceless, and the CMB addons go a long way.
Report
I’ve used ACF a few times on request, but by choice I always use CMB. The code-base in CMB is far better. The code-base in CMB2 is on par with the original IMO, but it has improved functionality, so generally seems to be the better option to use.
For very simple meta boxes, I still prefer to do things the old fashioned way though (via hand-coding every thing).
Report
This might be an obnoxious question to leave here, but is there any other resource for adding your own custom field types in CMB2, other than the main GitHub page for it? I’m trying to create a mix between
textarea
andtextarea_code
(basically, a non-WYSIWYG textarea, that will still allow basic HTML to work), but getting very lost in the details of how to go about this. Any advice would be much appreciated.Report
And now, embarrassingly, I’ve discovered that I shouldn’t need a custom field type for this. I should just be able to change
rows
in theattribute
array, but for some reason, that’s not working for me. Ah, well, such is life, and I’ll work on that. Sorry to pester you all.Report
Comments are closed.