Last active
September 8, 2021 15:51
-
-
Save hirozed/a008093807b307e0a99bb2b99f4693dd to your computer and use it in GitHub Desktop.
WordPress CMB2 Base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Reason for CMB2 box | |
*/ | |
function cmb2_admin_init() { | |
$prefix = 'add_prefix_here'; | |
// Create the box. | |
$cmb2 = \new_cmb2_box( | |
array( | |
'id' => '[CHANGEME-id]', | |
'title' => __( '[CHANGEME-title]', '[CHANGEME-localization]' ), | |
'object_types' => array( | |
'page', | |
), | |
'context' => 'normal', | |
'priority' => 'default', | |
'show_names' => true, | |
'show_on' => array( | |
'key' => 'page-template', | |
'value' => array( | |
'page-templates/[CHANGEME-page-template].php', | |
), | |
), | |
) | |
); | |
// Add fields below. | |
} | |
add_action( 'cmb2_admin_init', __NAMESPACE__ . '\\cmb2_admin_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment