foreach ($tablets as $post_id => $tablet) { $tpl = '<li id="ts%1$s">%2$s</li>'; if ($first === $post_id) { // add class .active.in for first element $tpl = '<li class="active in" id="ts%1$s">%2$s</li>'; } printf($tpl, $post_id, wp_get_attachment_image($tablet, 'full')); } unset($tablets, $tpl, $first, $post_id, $tablet); ?> </ul> </div> </div> <div class="phone"> <img src="<?php Appica_Helpers::image_uri("assets/img/iphone-{$color}.png"); ?> " alt="iPhone"> <div class="mask"> <ul class="screens"><?php /* * Phones */ $phones = array_key_exists('phones', $entries) ? (array) $entries['phones'] : array(); $first = null; if (count($phones) > 0) { reset($phones); $first = key($phones); } foreach ($phones as $post_id => $phone) { $tpl = '<li id="ps%1$s">%2$s</li>';