0

I have a popup panel being used for when someone clicks on view bio it will display their bio along with their name and headshot. As of right now I have four members being displayed M1 M2 M3 and M4. No matter which member bio I click the popup will only generate M1 bio. What am I doing wrong? I would like each popup to display the proper content based on the member i select.

This members are being generated in the backend by a repeatable field.

 <?php global $post; $entries = get_post_meta( get_the_ID(), '_cmb_members', true ); foreach ( $entries as $key => $entry ) {?>
  <article class="aboutWrapper">
     <ul>
        <li><img src="<?php echo $entries [$key]['_cmb_headshot'];?>" alt="<?php echo get_the_title(); ?>"/></li>
        <li><h3><?php echo $entries [$key]['name'];?></h3></li>
        <li><p><?php echo $entries [$key]['title']; ?></p></li>
        <li><button class="md-trigger" data-modal="modal-1">View Bio</button></li>
     </ul>
  </article>
  <!-- POPUP MENU -->
  <div class="md-modal md-effect-1" id="modal-1">
     <div class="md-content">
        <h3><?php echo $entries [$key]['name'];?></h3>
           <div>
              <p>This is a modal window. You can do the following things with it:</p>
              <button class="md-close">Close me!</button>
           </div>
     </div>
  </div>
 <!-- POPUP END -->
  <?php } //endforeach ?>
  • all of your modals have the same id: id="modal-1". – Milo Apr 24 '15 at 16:10
  • the id controls the styling and effect of the popup @Milo – user3756781 Apr 24 '15 at 16:15
  • 2
    id's must be unique. the view bio links are all hardcoded to data-modal="modal-1", which will always give you the first instance. use classes for styling. – Milo Apr 24 '15 at 16:19
  • Yup ignore what I just wrote I got it to work with what you said. Thank you @Milo – user3756781 Apr 24 '15 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.