WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using WPAlchemy to create meta boxes. What I want to do is 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.

$items = array('a', 'b', 'c');
while ($mb->have_fields('cb_ex', count($items))) {
    $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/>

How can I do this?

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
Please add your solution as a real answer and mark the question as answered. – toscho Jul 30 '12 at 19:40

Your Answer


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

Browse other questions tagged or ask your own question.