Skip to content

Instantly share code, notes, and snippets.

@farinspace
Created March 15, 2012 16:35
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/2045167 to your computer and use it in GitHub Desktop.
Save farinspace/2045167 to your computer and use it in GitHub Desktop.
<div class="my_meta_control">
<h4>Links</h4>
<a href="#" class="dodelete-links button">Remove All Links</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras orci lorem, bibendum in pharetra ac, luctus ut mauris.</p>
<?php while($mb->have_fields_and_multi('links')): ?>
<?php $mb->the_group_open(); ?>
<a href="#" class="dodelete button">Remove Link</a>
<?php $mb->the_field('title'); ?>
<input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/>
<?php $mb->the_field('url'); ?>
<input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/>
<?php $mb->the_group_close(); ?>
<?php endwhile; ?>
<p><a href="#" class="docopy-links button">Add Link</a></p>
</div>
<?php
$custom_mb = new WPAlchemy_MetaBox(array
(
'id' => '_custom_meta',
'title' => 'My Custom Meta',
'template' => get_stylesheet_directory() . '/custom/meta.php'
));
/* eof */
<?php
global $custom_mb;
$custom_mb->the_meta();
if ($custom_mb->have_value('links')) { ?>
<ul>
<?php while($custom_mb->have_fields('links')) { ?>
<?php if ($custom_mb->have_value('url') && $custom_mb->have_value('title')) { ?>
<li><a href="<?php $custom_mb->the_value('url'); ?>"><?php $custom_mb->the_value('title'); ?></a></li>
<?php } ?>
<?php } ?>
</ul>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment