• Hey guys Ive created a slider using post_meta thanks to tutorial and working on it to make it as i wish,i got the while loop code belove. Im trying to add class to current item of the loop. I used if statement to achieve this, however it adds the current to every item. Not only to the one what is being displayed. So I cud do anything to the displayed item, witohut changing others. Can anyone help me ?? ?

    <?php
                    // The Loop
                    $IDOutsideLoop = $post->ID;
                    while ( $the_query->have_posts() ) : $the_query->the_post();
     ?>
                        <li id="test">
    
    <?php   // The Slide's Image
                        if(has_post_thumbnail()) {
    $image_src = wp_get_attachment_image_src( get_post_thumbnail_id(),'full' );
     echo '<img src="' . $image_src[0]  . '" width="100%"  />';
    }
                        ?>
    
    <div id="slider_tlo">
    <?php
                             if ( get_post_meta( get_the_id(), 'wptuts_slideurl_tekst', true) != '' ) {?>
                             <span class="test3<?php
     if($IDOutsideLoop == $post->ID) 
    
        {
          echo "current";
           }
          ?>" id="caption"><?php echo ( get_post_meta( get_the_id(),'wptuts_slideurl_tekst', true) ); ?></span>  <?php } ?>
                             <?php
                             if ( get_post_meta( get_the_id(), 'wptuts_slideurl_opis', true) != '' ) {?>
                            ?>">
     </div>
       </li>
                    <?php endwhile; ?>

  • The topic ‘addding class to current item from the loop’ is closed to new replies.