Support

Account

Forum Replies Created

  • For anyone out there. This was the end result, it works.

    Basically I’m generating a shortcode for each row in the back-end. And with an object field, you can pick your products.

    <?php while(the_repeater_field('product_rows')) : ?>
        <?php $products = get_sub_field('select_products') ?>
        <li>
            <?php echo do_shortcode("[products ids='".implode(',',$products)."']"); ?>
        </li>
    <?php endwhile; ?>

    Chris

  • Ended up needing way less code.

    The below is fixing the issue.

    <?php while(the_repeater_field('product_rows')) : ?>
    <?php $products = get_sub_field('select_products'); ?>
        <?php the_sub_field('select_products') ?>
    <?php endwhile; ?>

    Thanks
    Chris

  • Hey there,

    $page_id is set just above the snippet. However, it was causing the issue. When I removed $page_id, I got it working.

    Thanks
    Chris

  • Never mind, found the issue. I had to set the variable this way:

    $image = get_field('category_image', $category);

    Hope this helps anyone else.

    Thanks
    Chris

  • Never mind, solved it.

    For anyone else with the same issue, here is how to do it.

    <?php
    	
    	if ( is_shop() ){
    		$page_id = get_option( 'woocommerce_shop_page_id' ); 
    	}
    	else {
    		$page_id = get_the_ID();
    	}
    
    if( have_rows('page_sliders', $page_id) ): ?>
    
    	<div id="carouselControls" class="carousel slide" data-ride="carousel">
    		<div class="carousel-inner">
    			<?php while( have_rows('page_sliders', $page_id) ): the_row(); 
    				// vars
    				$image = get_sub_field('slide_image', $page_id);
    				$link = get_sub_field('slide_image_url', $page_id);
    				$row = get_field('page_sliders', $page_id);
    				$rows = count($row);
    				?>
                    <div class="carousel-item <?php if (get_row_index() == 1) echo "active"; ?>">
    					<?php if( $link ): ?>
    						<a href="<?php echo $link['url']; ?>">
    					<?php endif; ?>
    						<img src="<?php echo esc_url($image['url']) ?>" alt="<?php echo $image['alt'] ?>" />
    					<?php if( $link ): ?>
    						</a>
    					<?php endif; ?>
    				</div>
    			<?php endwhile; ?>
    			<?php if ($rows > 1): ?>
                    <a class="carousel-control-prev" href="#carouselControls" role="button" data-slide="prev">
                        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                        <span class="sr-only">Previous</span>
                    </a>
                    <a class="carousel-control-next" href="#carouselControls" role="button" data-slide="next">
                        <span class="carousel-control-next-icon" aria-hidden="true"></span>
                        <span class="sr-only">Next</span>
                    </a>
                <?php endif; ?>
    		</div>
    	</div>
    
    <?php endif; ?>

    Kind regards
    Chris

  • Hey there,

    Just a quick question, how do I link each image in a gallery to a different page?

    Kind regards
    Chris

Viewing 6 posts - 1 through 6 (of 6 total)