Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save yoclove/44c7884ab2ec0b8ef1453274e8205876 to your computer and use it in GitHub Desktop.

Select an option

Save yoclove/44c7884ab2ec0b8ef1453274e8205876 to your computer and use it in GitHub Desktop.

Revisions

  1. John McCarthy revised this gist Jun 1, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions register_cmb2_metabox_after_title.php
    Original 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' ),
    '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' );
    cmb2_get_metabox( '_source_demo_metabox' )->show_form();
    }
    add_action( 'edit_form_after_title', 'source_output_custom_mb_location' );
  2. John McCarthy revised this gist Jun 1, 2015. 1 changed file with 11 additions and 18 deletions.
    29 changes: 11 additions & 18 deletions register_cmb2_metabox_after_title.php
    Original file line number Diff line number Diff line change
    @@ -1,35 +1,28 @@
    <?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
    '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' );
  3. John McCarthy created this gist Jun 1, 2015.
    35 changes: 35 additions & 0 deletions register_cmb2_metabox_after_title.php
    Original 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',
    ) );