How can I output WPAlchemy repeating fields meta values in my page template?
-
I have a custom post type, Downloads, which contains some custom metaboxes, including a repeating field. I’m able to output the values for all of them in my page template, but I’m not able to output the repeating fields’ values in my page template.
In my downloads_meta.php, I have the following:
<div class="my_meta_control">
<label>Includes:</label>
<?php $metabox->the_field('cb_second_includes'); ?>
<p><input type="checkbox" class="second-includes-check" name="<?php $metabox->the_name(); ?>" value="1"<?php $metabox->the_checkbox_state('1'); ?>/><span>Different bullet points for previous version?</span></p>
<div class="clearfix">
<?php while($metabox->have_fields_and_multi('docs')): ?>
<?php $metabox->the_group_open(); ?>
<?php $metabox->the_field('li-text'); ?>
<?php $wpalchemy_media_access->setGroupName('li-n'. $mb->get_the_index())->setInsertButtonLabel('Insert'); ?>
<div class="col includes">
<?php echo $wpalchemy_media_access->getField(array('name' => $metabox->get_the_name(), 'value' => $metabox->get_the_value())); ?>
<a href="#">-</a>
</div>
<?php $metabox->the_group_close(); ?>
<?php endwhile; ?>
</div>
<p style="margin-bottom:0; padding-top:0;"><a href="#">+</a></p>
</div>
And in my page template I have:
<?php
$args = array(
// 'posts_per_page' => 4,
'post_type' => array('downloads'),
'post_status' => 'publish',
'orderby' => 'menu_order',
'order' => 'ASC'
);
$temp = $wp_query;
global $wp_query;
global $post;
$wp_query= null;
$wp_query = new WP_Query($args);
?>
<?php
if($wp_query->have_posts()) :
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<?php
global $downloads_meta;
?>
<ul>
<?php while($downloads_meta->have_fields('docs')): ?>
<li><?php echo $downloads_meta->get_the_value('li-text'); ?></li>
<?php endwhile; ?>
</ul>
<?php
endwhile;
endif;
?>
With the above code, I’m able to output values for my first custom post type, but the second two don’t output anything for the repeating fields. I would appreciate any insights into what I might be doing wrong.
- The topic ‘How can I output WPAlchemy repeating fields meta values in my page template?’ is closed to new replies.