Skip to content

Instantly share code, notes, and snippets.

@farinspace
Forked from kirstenkeister/project-meta.php
Created January 19, 2012 17:17
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 farinspace/1641284 to your computer and use it in GitHub Desktop.
Save farinspace/1641284 to your computer and use it in GitHub Desktop.
WPAlchemy meta definitions for project-meta
<div class="my_meta_control">
<a style="float:right; margin:0 10px;" href="#" class="dodelete-links button remove-all">Remove All</a>
<label>Project Staff<span>(current Staff associated with the project)</span></label>
<p>Add staff to project by selecting them from the dropdown. Add addtional staff by clicking the "Add Staff" button.</p>
<?php
$people_query_args = array(
'post_type' => 'people',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
);
$people_query = new WP_Query( $people_query_args );
$staff_arr = array();
if ( $people_query->have_posts() )
{
while ( $people_query->have_posts() )
{
$people_query->the_post();
array_push( $staff_arr, array( 'id' => $post->ID , 'title' => $post->post_title ) );
}
}
?>
<?php while($mb->have_fields_and_multi('links')): ?>
<?php $mb->the_group_open(); ?>
<?php $mb->the_field( 'projectstaff' ); ?>
<select name="<?php $mb->the_name(); ?>">
<option value="">Select...</option>
<?php foreach( $staff_arr as $staff ) { ?>
<option value="<?php echo $staff['id']; ?>"<?php $mb->the_select_state($staff['id']); ?>><?php echo $staff['title']; ?></option>
<?php } ?>
</select>
<p class="remove-button"><a href="#" class="dodelete button remove">Remove Link</a></p>
<br clear="all" />
<?php $mb->the_group_close(); ?>
<?php endwhile; ?>
<p class="add-another-link"><a href="#" class="docopy-links button add-another">Add Link</a></p>
</div>
$project_mb = new WPAlchemy_MetaBox(array(
'id' => '_project_details',
'title' => 'Project Details',
'types' => array('project'),
'context' => 'normal',
'priority' => 'high',
'mode' => WPALCHEMY_MODE_EXTRACT,
'template' => get_stylesheet_directory() . '/metaboxes/project-meta.php'
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment