WPAlchemy - Trying to get pages


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php while( $mb->have_fields_and_multi( 'buttons' ) ) : ?>
  2. <?php $mb->the_group_open(); ?>
  3. <div class="button">
  4. <?php
  5. $pages = get_pages();
  6. $selected = ' selected="selected"';
  7. $mb->the_field('s_field');
  8. ?>
  9. <select name="<?php $mb->the_name(); ?>">
  10. <?php
  11. foreach ($pages as $pagelist => $page) {
  12. echo '<option value="'. $page->ID .'"'; $thevalue = $page->ID; if ( $mb->get_the_value() == "$thevalue") echo $selected; echo '>' . $page->post_name .'</option>';
  13. }
  14. ?>
  15. </select>
  16. </div>
  17. <?php $mb->the_group_close(); ?>
  18. <?php endwhile; ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.