
Hi folks,
I am trying to get two repeater sections to work, the first shows but the latter doesn’t. I have removed the first repeater code in order to get the 2nd to show but still doesn’t work.
Here is the code:
<?php if( have_rows('woocommerce_category_boxes') ):?>
<ul class="woocommerce-products-cats">
<?php // loop through the rows of data
while ( have_rows('woocommerce_category_boxes') ) : the_row(); ?>
<li>
<img src="<?php the_sub_field('image'); ?>" />
<?php the_sub_field('title'); ?>
<?php the_sub_field('link'); ?>
</li>
<?php
endwhile;
else :
// no rows found?>
</ul>
<?php endif;?>
Second Repeater:
<?php if( have_rows('woocommerce_on_sale_boxes') ): ?>
<ul>
<?php while( have_rows('woocommerce_on_sale_boxes') ): the_row();
// vars
$image_product = get_sub_field('image_product');
$title_product = get_sub_field('title_product');
$link_product = get_sub_field('link_product');
$price_product = get_the_field('price_product');
?>
<li>
<?php if( $link_product ): ?>
<a href="<?php echo $link_product; ?>">
<?php endif; ?>
<img src="<?php echo $image_product['url']; ?>" alt="<?php echo $image_product['alt'] ?>" />
<?php if( $link_product ): ?>
</a>
<?php endif; ?>
<?php echo $title_product; ?>
<?php echo $price_product; ?>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
Any suggestions? Cheers 🙂
Found my issue I wrote:
$price_product = get_the_field('price_product');
Should have been
$price_product = get_sub_field('price_product');
Cheers 🙂