Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Metabox to save store information
<?php
/**
* Metabox to save store information
*
* @author Phil Wylie
* @link http://goo.gl/zJwIk5
*/
function pw_register_store_metabox( $meta_boxes ) {
$prefix = '_cmb_'; // Prefix for all fields
$meta_boxes[] = array(
'id' => 'store_meta_box',
'title' => 'Store Information',
'pages' => array( 'store' ), // post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => array(
array(
'name' => 'Phone',
'id' => $prefix . 'phone',
'type' => 'text_medium',
),
array(
'name' => 'Location',
'desc' => 'Drag the marker to set the exact location',
'id' => $prefix . 'location',
'type' => 'pw_map',
),
),
);
return $meta_boxes;
}
add_filter( 'cmb_meta_boxes', 'pw_register_store_metabox' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment