Support

Account

Forum Replies Created

  • Thanks James! I will give that a try. Appreciate it!

  • I actually had the repeater loop code but just didn’t post it. I was able to solve it though! I needed a PHP increment bit of code to get it working. Here is the final code in case it helps anyone else:

    <?php if( have_rows('api_properties') ): ?>
       <?php $id_increment = 0; ?>
    
    	<?php while ( have_rows('api_properties') ) : the_row(); ?>
    
    		<li>
    
    		<?php 
    			$name = get_sub_field('api_name'); 
    			$value = get_sub_field('api_value');
    			$posts = get_sub_field('api_references');
    		?>
    
    		<?php if( $posts ): ?>
    
    			<h3 class="api-category"><!-- Button trigger modal -->
    			<button onclick="document.getElementById('id1_<?php echo $id_increment; ?>').style.display='block'" class="w3-button"></button><?php echo $name; ?></h3>
    			<p class="api-name"><?php echo $value; ?></p>
    
    			<div id="id1_<?php echo $id_increment; ?>" class="w3-modal">
    				<div class="w3-modal-content">
    				  <header class="w3-container w3-teal"> 
    					<span onclick="document.getElementById('id1_<?php echo $id_increment; ?>').style.display='none'" 
    					class="w3-button w3-display-topright">&times;</span>
    					<h3>References</h3>
    					</header>
    
    				<div class="w3-container results">
    				<table width="100%" cellpadding="0" cellspacing="0" border="0">
    					<tr>
    						<td class="header">Title</td>
    						<td class="header">Description</td>
    						<td class="header number">Ref #</td>
    						<td class="header">PDF</td>
    					</tr>      
    
    					<?php foreach( $posts as $p ): ?>
    						<tr>
    							<td><?php echo get_the_title( $p->ID ); ?></td>
    							<td><?php echo get_field('reference_description', $p->ID); ?></td>
    							<td class="number"><?php echo get_field('reference_number', $p->ID); ?></td>
    							<td><?php echo get_field('reference_pdf', $p->ID); ?></td>
    						</tr>
    					<?php endforeach; ?>
    
    				  </table>
    			  </div>
    			  <footer class="w3-container">
    				<p>&nbsp;</p>
    			  </footer>
    		  </div>
    
    		 <?php $id_increment++; ?>
    
    		</div>
    
    		<?php else : ?>
    
    		<h2 class="api-category"><?php echo $name; ?></h2>
    		<p class="api-name"><?php echo $value; ?></p>
    
    		<?php endif; ?>
    
    	</li>
    
    <?php endwhile; ?>
    <?php endif; ?>
    <?php wp_reset_postdata(); ?>
Viewing 2 posts - 1 through 2 (of 2 total)