-
-
Save farinspace/1116182 to your computer and use it in GitHub Desktop.
WPAlchemy - Issue getting value pulled into page template
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 | |
// add Gallery Images custom meta box | |
$mgallery = new WPAlchemy_MetaBox(array | |
( | |
'id' => '_gallery_main', | |
'title' => 'Gallery Images', | |
'types' => array('gallery_main'), // added only for pages | |
'context' => 'normal', // same as above, defaults to "normal" | |
'priority' => 'high', // same as above, defaults to "high" | |
'template' => TEMPLATEPATH . '/custom/gallery_images_repeatingfields.php', | |
'hide_editor' => TRUE | |
)); | |
?> |
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 $mgallery; ?> | |
<?php $loop = new WP_Query( array( 'post_type' => 'gallery_main', 'posts_per_page' => -1 ) ); ?> | |
<?php while ($loop->have_posts()) { ?> | |
<?php $loop->the_post(); $mgallery->the_meta($post->ID); ?> | |
<div class="mgallery"> | |
<?php $gallery_images = $mgallery->get_the_value('gallery_image'); ?> | |
<?php $i = 0; foreach ($gallery_images as $v) { ?> | |
<img class="gimage<?php echo (!$i) ? ' first' : '' ; ?>" src="<?php echo $v['imgurl']; ?>" alt="<?php echo $v['title']; ?>"/> | |
<?php $i++; } ?> | |
</div><!-- end mgallery --> | |
<?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
<?php global $wpalchemy_media_access; ?> | |
<div class="my_meta_control"> | |
<p><a href="#" class="dodelete-gallery_image button">Remove All</a></p> | |
<?php while($mb->have_fields_and_multi('gallery_image')): ?> | |
<?php $mb->the_group_open(); ?> | |
<a href="#" class="dodelete button">Remove</a> | |
<?php $mb->the_field('imgurl'); ?> | |
<?php $wpalchemy_media_access->setGroupName('n' . $mb->get_the_index())->setTab('type'); ?> | |
<!-- label of insert button in media uploader box --> | |
<p> | |
<?php echo $wpalchemy_media_access->getField(array('name' => $mb->get_the_name(), 'value' => $mb->get_the_value())); ?> | |
<?php echo $wpalchemy_media_access->getButton(array('label' => 'Add Image to Gallery')); ?> | |
</p> | |
<?php $mb->the_field('title');?> | |
<label for="<?php $mb->the_name(); ?>">Title</label> | |
<p><input type="text" id="<?php $mb->the_name(); ?>" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/></p> | |
<?php $mb->the_field('gname');?> | |
<label for="<?php $mb->the_name(); ?>">Gallery Name</label> | |
<p><input type="text" id="<?php $mb->the_name(); ?>" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/></p> | |
<?php $mb->the_group_close(); ?> | |
<?php endwhile; ?> | |
<p style="margin-bottom:15px; padding-top:5px;"><a href="#" class="docopy-gallery_image button">Add</a></p> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment