Created
February 12, 2015 19:06
-
-
Save LinzardMac/dc99cb97c3ebe6b602b6 to your computer and use it in GitHub Desktop.
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 characters
$prefix = 'custom_'; | |
$custom_meta_fields = array( | |
array( | |
'label' => 'Multi-Day', | |
'desc' => '', | |
'id' => $prefix.'multiday', | |
'type' => 'checkbox' | |
), | |
array( | |
'label' => 'Recurring', | |
'desc' => '', | |
'id' => $prefix.'recurring', | |
'type' => 'checkbox' | |
), | |
array( | |
'label'=> 'Free Admission? ', | |
'desc' => 'Check box if admission if free', | |
'id' => $prefix.'cost_free', | |
'type' => 'checkbox' | |
) | |
); | |
// Begin the field table and loop | |
echo '<table class="form-table">'; | |
foreach ($custom_meta_fields as $field) { | |
// get value of this field if it exists for this post | |
$values = get_post_meta($post->ID, $field['id'], true); | |
if (isset($values)){ | |
$meta = $values; | |
}else{ | |
$values = null; | |
} | |
// begin a table row with | |
echo '<tr> | |
<th><label for="'.$field['id'].'">'.$field['label'].'</label></th> | |
<td>'; | |
switch($field['type']) { | |
case 'checkbox': | |
echo '<input type="checkbox" name="'.$field['id'].'" class="'.$field['id'].'" id="'.$field['id'].'" ',$meta ? ' checked="checked"' : '','/> | |
<label for="'.$field['id'].'">'.$field['desc'].'</label>'; | |
break; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment