Created
March 16, 2016 16:14
-
-
Save codenameEli/5fb697722d8e0c5b07c7 to your computer and use it in GitHub Desktop.
Dynamically customize Slick Slider dots style depending on index of loop.
This file contains 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
<?php | |
function tower_do_single_product_variation_preview_images() | |
{ | |
global $post; | |
$variations = get_field( 'product_variation' ); | |
?> | |
<div id="productVariationDotsContainer"> | |
<?php | |
foreach ( $variations as $key => $variation ) { | |
$image = $variation['product_variation_preview_image']; | |
$index = $key; | |
if ( empty( $image ) ) { | |
continue; | |
} | |
if ( $index < 10 ) { | |
$index = '0' . strval( $index ); | |
} | |
?> | |
<style type="text/css"> | |
#productVariationDotsContainer #slick-slide<?php echo $index; ?> button { | |
background-image: url( <?php echo $image['sizes']['tower-acf-product-variation-preview']; ?> ); | |
} | |
</style> | |
<?php | |
} | |
?> | |
</div> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment