0

I'm new to Wordpress and am having trouble getting my loop to make the_content() not repeat itself. I've tried writing multiple loops as well to no avail. I mainly just want the_content() to iterate inside of the reveal modal.

 <?php $loop = new WP_Query( array( 'post_type' => 'c3k_project', 'posts_per_page' => 8 ) ); ?>
  <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="grid-item">
  <a href="#" data-reveal-id="myModal">
    <figure class="text-overlay">
      <?php if (has_post_thumbnail( $post->ID ) ): ?>
    <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
    <img src="<?php echo $image[0]; ?>">
      <?php endif; ?>
      <figcaption>
    <h3><?php the_title(); ?></h3>
    <?php the_excerpt(); ?>
    <?php the_author(); ?>
      </figcaption>
    </figure>
  </a>
</div>

<div id="myModal" class="reveal-modal full chicken-modal" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
  <div class="row">
    <div class="medium-12 columns">

      <?php the_content(); ?>

    </div>
  </div>
  <a class="close-reveal-modal" aria-label="Close">&#215;</a>
</div>

  <?php endwhile; wp_reset_query(); ?>
0

Solved. This was due to reveal using an ID (see myModal ID) and iterating the same ID over and over again. As a fix, I used:

id="modal-<?php echo get_the_ID(); ?>"

This has solved my issue of the_content() repeating its first iteration over and over.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.