Last active
November 15, 2017 08:33
-
-
Save yuriitaran/dd49bdb7681d65e7d9f7e03313dd9ef0 to your computer and use it in GitHub Desktop.
ACF repeater loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For Post Type | |
| <?php $the_query = new WP_Query( array( 'post_type' => 'contacts', 'order' => 'ASC', ) ); | |
| if ( $the_query->have_posts() ) : ?> | |
| <ul class="footer-contacts"> | |
| <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> | |
| <?php if( have_rows('contact_types') ): ?> | |
| <?php while( have_rows('contact_types') ): the_row(); ?> | |
| <li> | |
| <?php if (get_sub_field('contact_type')): ?> | |
| <span class="contact-title"><?php the_sub_field('contact_type'); ?></span> | |
| <?php endif; ?> | |
| <?php if( have_rows('contact_values') ): ?> | |
| <?php while( have_rows('contact_values') ): the_row(); ?> | |
| <?php if( preg_match("/[0-9a-z]+@[a-z]/", get_sub_field('contact_value')) && get_sub_field('contact_value')) : ?> | |
| <span><a href="mailto:<?php the_sub_field('contact_value'); ?>"><?php the_sub_field('contact_value'); ?></a></span> | |
| <?php elseif(get_sub_field('contact_value')): ?> | |
| <span><?php the_sub_field('contact_value'); ?></span> | |
| <?php endif; ?> | |
| <?php endwhile; ?> | |
| <?php endif; ?> | |
| </li> | |
| <?php endwhile; ?> | |
| <?php endif; ?> | |
| <?php endwhile; ?> | |
| </ul> | |
| <?php wp_reset_postdata(); | |
| endif; ?> | |
| // For Theme Options | |
| <?php if( have_rows('contact_types','options') ): ?> | |
| <ul class="footer-contacts"> | |
| <?php while ( have_rows('contact_types','options') ) : the_row(); ?> | |
| <li> | |
| <span class="contact-title"><?php the_sub_field('contact_type'); ?></span> | |
| <?php while( have_rows('contact_values') ): the_row(); ?> | |
| <span><?php the_sub_field('contact_value'); ?></span> | |
| <?php endwhile; ?> | |
| </li> | |
| <?php endwhile; ?> | |
| </ul> | |
| <?php endif;?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment