mercredi 3 juin 2015

Increment value by one on each instance

hi have been workin on this .i need to increment the value of i on ech instance of the condition.currently i have three.the code below

<?php  if( !empty($instance['link']) ): ?>
    <div class="caption lft slide-heading" data-x="580" data-y="30" data-speed="1800" data-start="1200" data-easing="easeOutExpo">
        <a href="<?php echo $instance['link']; ?>">
            <?php if( !empty($instance['title']) ): echo apply_filters('widget_title', $instance['title']); endif; ?>
        </a>
    </div>
    <!-- FOCUS HEADING -->
<?php endif;?>

i tried

<?php   $i=0;$i++; if( !empty($instance['link']) ):  ?>
    <div class="caption lft slide-heading" data-x="580" data-y="30" data-speed="1800" data-start="1200" data-easing="easeOutExpo">   
        <a href="<?php echo $instance['link']; ?>"> 
            <?php if( !empty($instance['title']) ): echo apply_filters('widget_title', $instance['title']); endif; ?>
        </a>
    </div>
    <!-- FOCUS HEADING -->
<?php  echo $i; endif; ?>

this results 1 1 1 . I would like to get it as 1 2 3. where did i went wrong? please help

Aucun commentaire:

Enregistrer un commentaire