Skip to content

Instantly share code, notes, and snippets.

@codenameEli
Created March 16, 2016 16:14
Show Gist options
  • Save codenameEli/5fb697722d8e0c5b07c7 to your computer and use it in GitHub Desktop.
Save codenameEli/5fb697722d8e0c5b07c7 to your computer and use it in GitHub Desktop.
Dynamically customize Slick Slider dots style depending on index of loop.
<?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