Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amanhstu/7f9de7e14fcb8e3367750e4f3e76a7ba to your computer and use it in GitHub Desktop.
Save amanhstu/7f9de7e14fcb8e3367750e4f3e76a7ba to your computer and use it in GitHub Desktop.
<?php while ( have_posts() ) : the_post(); ?>
<div class="main-content">
<div class="main-wrap">
<?php // check for rows (parent repeater)
if( have_rows('product_page') ): ?>
<div class="col-lg-12 row product-row">
<?php // loop through rows (parent repeater)
while( have_rows('product_page') ): the_row(); ?>
<div class="col-sm-12">
<div class="marque">
<span class="brand-lg"><img src="<?php the_sub_field('brand_image'); ?>" /></span>
</div>
</div>
<?php // check for rows (sub repeater)
if( have_rows('post_repeater') ):
?>
<div class="col-sm-12 product-item-row">
<?php // loop through rows (sub repeater)
while( have_rows('post_repeater') ): the_row();?>
<div class="col-sm-3 product-item">
<?php
$postobject = get_sub_field('product_post');
$image = wp_get_attachment_image_src(get_post_thumbnail_id( $postobject->ID ),'medium');
$image = $image[0];
?>
<a href="<?php echo get_permalink($postobject->ID);?>">
<?php if ( get_field( 'new_product_item',$postobject->ID) ): ?>
<img class="new-label-en" src="<?php bloginfo('template_directory');?>/images/label-en.png" />
<img class="new-label-fr" src="<?php bloginfo('template_directory');?>/images/label-fr.png" />
<img class="product-img" src="<?php echo $image;?>" width="100%" height="100%" />
<p class="product-name"><?php echo $postobject->post_title;?></p>
<p class="product-seemore"><?php echo $product_details_link_text;?></p>
<?php else: // field_name returned false ?>
<img class="product-img" src="<?php echo $image;?>" width="100%" height="100%" />
<p class="product-name"><?php echo $postobject->post_title;?></p>
<p class="product-seemore"><?php echo $product_details_link_text;?></p>
</a>
<?php endif; //if( get_sub_field): ?>
</div><!-- col ends here -->
<?php endwhile; ?>
</div><!-- col Product Items row here -->
<?php endif; //if( get_sub_field('items') ): ?>
<?php endwhile; // while( has_sub_field('to-do_lists') ): ?>
</div><!-- col lg 12 ends here or row ends here -->
<?php endif; // if( get_field('to-do_lists') ): ?>
<?php endwhile; // end of the loop. ?>
</div><!-- main wrap ends here -->
<div class="clr"></div>
</div><!-- main content ends here -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment