Skip to content

Instantly share code, notes, and snippets.

Created May 14, 2013 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5577399 to your computer and use it in GitHub Desktop.
Save anonymous/5577399 to your computer and use it in GitHub Desktop.
lschaef WPAlchemy Code
#-----------------------------------
# functions.php
#-----------------------------------
include_once 'metaboxes/setup.php';
include_once 'metaboxes/company-spec.php';
include_once 'metaboxes/name-spec.php';
include_once 'metaboxes/address-spec.php';
#-----------------------------------
# company-spec.php
#-----------------------------------
$custom_metabox = $simple_mb = new WPAlchemy_MetaBox(array
(
'id' => '_company_meta',
'title' => 'Company',
'types' => array('person','cable_station','cable_hub'),
'template' => get_stylesheet_directory() . '/metaboxes/company-meta.php',
));
#-----------------------------------
# company-meta.php
#-----------------------------------
<div class="my_meta_control">
<p>
<?php
$args = array('post_type' => 'cable_company', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC');
$query = new WP_Query( $args );
?>
<?php $mb->the_field('cable_company'); ?>
<select name="<?php $mb->the_name(); ?>">
<option value="">Select...</option>
<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
<option value="<?php echo get_the_id(); ?>"<?php $mb->the_select_state(get_the_id()); ?>><?php echo get_the_title(); ?></option>
<?php endwhile; else: ?>
<?php endif; ?>
</select>
</p>
</div>
#-----------------------------------
# name-spec.php
#-----------------------------------
$custom_metabox = $simple_mb = new WPAlchemy_MetaBox(array
(
'id' => '_name_meta',
'title' => 'Name',
'types' => array('person'),
'template' => get_stylesheet_directory() . '/metaboxes/name-meta.php',
));
#-----------------------------------
# name-meta.php
#-----------------------------------
<div class="my_meta_control">
<p>
<?php $mb->the_field('name_sal'); ?>
<select name="<?php $mb->the_name(); ?>">
<option value="">Select...</option>
<option value="Mr."<?php $mb->the_select_state('Mr.'); ?>>Mr.</option>
<option value="Mrs."<?php $mb->the_select_state('Mrs.'); ?>>Mrs.</option>
<option value="Miss."<?php $mb->the_select_state('Miss.'); ?>>Miss.</option>
</select>
<label class="inline fixed-width-65">First Name:</label>
<?php $mb->the_field('name_first'); ?>
<input class="medium" type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/>
<label class="inline">Initial:</label>
<?php $mb->the_field('name_initial'); ?>
<input class="small" type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/>
<label class="inline">Last Name:</label>
<?php $mb->the_field('name_last'); ?>
<input class="medium" type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/>
</p>
</div>
#========================
# address-spec.php
#------------------------
$custom_metabox = $simple_mb = new WPAlchemy_MetaBox(array
(
'id' => '_address_meta',
'title' => 'Address',
'types' => array('person','cable_company','cable_hub'),
'template' => get_stylesheet_directory() . '/metaboxes/address-meta.php',
));
#========================
# address-meta.php
#------------------------
<div class="my_meta_control">
<p>
<label class="inline fixed-width-65">Address:</label>
<?php $mb->the_field('address1'); ?>
<input class="medium" type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/><br>
<label class="inline fixed-width-65"></label>
<?php $mb->the_field('address2'); ?>
<input class="medium" type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/><br>
<label class="inline fixed-width-65">City:</label>
<?php $mb->the_field('address_city'); ?>
<input class="medium" type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/>
<label class="inline">State:</label>
<?php $mb->the_field('address_state'); ?>
<input class="small" type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/>
<label class="inline">Zip/Postal:</label>
<?php $mb->the_field('address_zip'); ?>
<input class="small" type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/><br>
</p>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment