Using Custom Meta Boxes in WordPress
1h 34mIntermediate2021-12-16
Authors

Joe Casabona
Course Developer, Founder of Creator Courses
Course details
When you're building your own plugin or theme, it's important to reduce the number of external dependencies that a site owner needs to use it. While there are a lot of great custom field plugins out there, CMB2 allows you to include it as a library in your own theme or plugin. In this course, Joe Casabona, course developer and founder of Creator Courses, walks you through how CMB2 works, when to use it, and how to build out a website using it within a custom plugin. Joe goes over defining custom fields, creating meta boxes, adding a custom field type, and adding fields to your meta boxes. He shows you how to add a file uploader, create a repeatable field, get data from CMB2, and much more. After covering how to build a post select box, Joe explores some noteworthy features, such as frontend meta box support, creating a theme options page, and adding fields to user profiles.
Skills covered
WordPressContent Management Systems (CMS)Web DevelopmentOpen SourceOne-Off
Concepts
Introduction
- Custom fields without dependency
- What you should know
- Demo project overview
How CMB2 Works
- What is CMB2 and how does it work
- The difference between CMB2 and ACF
- Installing CMB2 via the Plugin Directory
- Setting up our project plugin
- CMB2 as a library for your plugin
- The CMB2 documentation
- Field types in CMB2
- CMB2 and the block editor
Building Our Custom Fields
- Defining our custom fields
- Creating our meta boxes
- Adding a the custom field type
- Adding fields to our meta boxes
- Adding a file uploader
- Creating a repeatable field
- How to get data from CMB2
- Adding our custom fields to the frontend
- Displaying from a repeatable field
Creating a Post Select Box
- Building a post select box
- Updating the content output
Noteworthy Features
- Bringing in taxonomies
- Frontend Meta Box support
- Creating a theme options page
- Adding fields to user profiles
Conclusion
- Next steps