Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using WPAlchemy to create meta boxes. What I want to do to to dynamically create a group of check boxes with post titles.

In other words, I want to replace a, b and c with the query of post titles

<?php $items = array('a', 'b', 'c'); ?>

<?php while ($mb->have_fields('cb_ex', count($items))): ?>

    <?php $item = $items[$mb->get_the_index()]; ?>

    <input type="checkbox" name="<?php $mb->the_name(); ?>" value="<?php echo $item; ?>"<?php $mb->the_checkbox_state($item); ?>/> <?php echo $item; ?><br/>

<?php endwhile; ?>

I appreciate your help, as you may have noticed I'm not a code expert.

share|improve this question
I came across this solution that may help anyone looking for a way to display post titles. <?php $mb->the_field('icon-url'); ?> <?php $selected = ' selected="selected"'; ?> <select name="<?php $mb->the_name(); ?>"> <option value=""></option> <?php $terms = get_pages(); foreach ($terms as $taxindex => $taxitem) { echo '<option value="'. $taxitem->ID .'"'; $thevalue = $taxitem->ID; if ($mb->get_the_value() == "$thevalue") echo $selected; ?> <?php echo '>' . $taxitem->post_title .'</option>'; } ?> </select> – Boldhand May 16 '12 at 13:55
1  
Please add your solution as a real answer and mark the question as answered. – toscho Jul 30 '12 at 19:40

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.