-
-
Save jdickie/1712806 to your computer and use it in GitHub Desktop.
WPAlchemy meta definitions for repeating links
This file contains 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
<?php | |
global $peoplelinks_mb; | |
$peoplelinks_mb->the_meta(); | |
$i = 0; | |
while($peoplelinks_mb->have_fields('links')) { | |
?> | |
<?php | |
if($i == 0) { ?> | |
<div id="info-links" class="column left"> | |
<h2 class="column-title">Links</h2> | |
<ul> | |
<?php } ?> | |
<?php // loop a set of field groups | |
$url = $peoplelinks_mb->get_the_value('url'); | |
$title = $peoplelinks_mb->get_the_value('title'); | |
echo '<li><a href="' . $url . '" target="_blank" rel="nofollow">'; | |
echo $title . '</a></li>'; | |
<?php | |
$i++; | |
// End while loop | |
} | |
if($i > 0) { ?> | |
</ul> | |
</div> | |
<?php } ?> |
This file contains 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
<div class="my_meta_control"> | |
<div class="remove-all-button"><a href="#" class="dodelete-links button remove-all">Remove All</a></div> | |
<p>Add links by entering in a title in the first field and the URL in the second. Add a new link by clicking the "Add Link" button.</p> | |
<?php while($mb->have_fields_and_multi('links')): ?> | |
<?php $mb->the_group_open(); ?> | |
<?php $mb->the_field('title'); ?> | |
<p><input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/></p> | |
<?php $mb->the_field('url'); ?> | |
<p><input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/></p> | |
<div class="remove-button"><a href="#" class="dodelete button remove">Remove Link</a></div> | |
<br clear="all" /> | |
<?php $mb->the_group_close(); ?> | |
<?php endwhile; ?> | |
<div class="add-another-link"><a href="#" class="docopy-links button add-another">Add Link</a></div> | |
<br clear="all" /> | |
</div> |
This file contains 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
$peoplelinks_mb = new WPAlchemy_MetaBox(array( | |
'id' => '_people_links', | |
'title' => 'Links', | |
'types' => array('people'), | |
'mode' => WPALCHEMY_MODE_EXTRACT, | |
'template' => get_stylesheet_directory() . '/metaboxes/people-meta-links.php' | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Grant,
it looks like the is_first() and is_last() calls are to be used in the definitions of the metaboxes php file as opposed to this one. So maybe I can add the text there instead. I'll try it... unless you have another idea for how to references the first and last items of the loop.
Kirsten