Skip to content

Installation

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.

Bundled in 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.

Via Composer (PSR-4)

in composer.json file:

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

Via Composer (non-PSR-4)

in composer.json file:

json
{
	"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 for the CMB2 WordPress developer toolkit.