Forked from j-mccarthy/register_cmb2_metabox_after_title.php
Created
December 15, 2017 02:27
-
-
Save yoclove/44c7884ab2ec0b8ef1453274e8205876 to your computer and use it in GitHub Desktop.
Revisions
-
John McCarthy revised this gist
Jun 1, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ function source_banner_metabox() { $cmb_demo = new_cmb2_box( array( 'id' => $prefix . 'metabox', 'title' => __( 'Test Metabox', 'cmb2' ), // Kept this as I don't want to remove the metabox wrap 'object_types' => array( 'page' ), 'show_names' => true, ) ); @@ -23,6 +23,6 @@ function source_banner_metabox() { function source_output_custom_mb_location() { cmb2_get_metabox( '_source_demo_metabox' )->show_form(); } add_action( 'edit_form_after_title', 'source_output_custom_mb_location' ); -
John McCarthy revised this gist
Jun 1, 2015 . 1 changed file with 11 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,35 +1,28 @@ <?php add_action( 'cmb2_init', 'source_banner_metabox' ); function source_banner_metabox() { $prefix = '_source_demo_'; $cmb_demo = new_cmb2_box( array( 'id' => $prefix . 'metabox', 'title' => __( 'Test Metabox', 'cmb2' ), 'object_types' => array( 'page' ), 'show_names' => true, ) ); $cmb_demo->add_field( array( 'name' => __( 'Test Text', 'cmb2' ), 'desc' => __( 'field description (optional)', 'cmb2' ), 'id' => $prefix . 'text', 'type' => 'text', ) ); } function source_output_custom_mb_location() { cmb2_get_metabox( '_source_demo_metabox' ); } add_action( 'edit_form_after_title', 'source_output_custom_mb_location' ); -
John McCarthy created this gist
Jun 1, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ <?php function yourprefix_output_custom_mb_location() { cmb2_get_metabox( '_source_demo_metabox' ); } add_action( 'edit_form_after_title', 'yourprefix_output_custom_mb_location' ); add_action( 'cmb2_init', 'source_banner_metabox' ); /** * Hero/Banner for pages * * @see genesis_before_content * */ function source_banner_metabox() { // Start with an underscore to hide fields from custom fields list $prefix = '_source_demo_'; /** * Sample metabox to demonstrate each field type included */ $cmb_demo = new_cmb2_box( array( 'id' => $prefix . 'metabox', 'title' => __( 'Test Metabox', 'cmb2' ), 'object_types' => array( 'page' ), // Post type 'show_names' => true, // Show field names on the left ) ); $cmb_demo->add_field( array( 'name' => __( 'Test Text', 'cmb2' ), 'desc' => __( 'field description (optional)', 'cmb2' ), 'id' => $prefix . 'text', 'type' => 'text', ) );