Skip to content
Justin Sternberg edited this page Apr 5, 2020 · 15 revisions

Table of Contents generated with DocToc

If installing the plugin from wordpress.org:

  1. Upload the entire /CMB2 directory to the /wp-content/plugins/ directory.
  2. Activate CMB2 through the 'Plugins' menu in WordPress.
  3. Copy (and rename if desired) example-functions.php into to your theme or plugin's directory and require_once from your theme or plugin's main file.
  4. Edit to only include the fields you need and rename the functions.
  5. Profit.

If including the library in your plugin or theme:

  1. Place the CMB2 directory inside of your theme or plugin.
  2. Copy (and rename if desired) example-functions.php into a folder above the CMB2 directory OR copy the entirety of its contents to your theme's functions.php file.
  3. Edit to only include the fields you need and rename the functions (CMB2 directory should be left unedited in order to easily update the library).
  4. Profit.

Important Notes

  • Please review the caveats for bundling and including CMB2 .
  • when bundling CMB2 with your theme or plugin, you will want to use the release package. You can download the zip file from the WordPress plugin repo, or using the download link on Github. It is recommended that you not clone CMB2 into your project. This will ensure your bundled version does not contain the development-only files/folders.

If including the library via composer in PSR-4 format (Example Antonella Framework)

in composer.json file:

"require": {
	"cmb2/cmb2": "dev-master"
},
"autoload": {
	"files": ["vendor/cmb2/cmb2/init.php"]
}

If including the library via composer (not PSR-4 format)

in composer.json file:

{
	"require": {
		"php": ">=5.3.0",
		"composer/installers": "v1.0.12",
		"cmb2/cmb2": "dev-master"
	},
	"autoload": {
		"files": ["vendor/cmb2/init.php"]
	},
	"extra": {
		"installer-paths": {
			"vendor/{$name}/": ["cmb2/cmb2"]
		}
	} 
}

Documentation:

  1. Home

  2. Installation
    Installation instructions for various environments

  3. Basic Usage
    Get up and running

  4. Advanced Usage
    Not for the faint of heart

  5. Field Types
    Breakdown of field types

  6. Examples
    Examples for registering fields

  7. Field Parameters
    Breakdown of common field parameters

  8. Display Options
    Limit display of boxes

  9. Box Properties
    Breakdown of box properties

  10. Troubleshooting
    Common issues & how to deal with them

  11. Notable Changes in CMB2 (from original CMB)
    CMB2 — a complete re-write

  12. Tips & Tricks
    10x your CMB2 skills

  13. REST API
    CMB2 data through WordPress REST API

  14. Javascript API
    Work with CMB2 JS events & hooks

Advanced tutorials:

External Resources:

Clone this wiki locally