Support » Themes and Templates » Giving a different id to every list item

  • atlanteavila


    Hi all, I need help with figuring out how to give a different ID to every list item for styling purposes. So I have a custom taxonomy with a custom loop which is this:

    <?php $counter =0; ?>
    <?php while ( have_posts() ) : the_post(); ?>
      if($counter == 4) {
        $postclass = 'class="fourth-post"';
        $counter = 0;
      } else { $postclass = ''; }
    <li <?php echo $postclass; ?> style="position: relative; z-index: 10; overflow: hidden; text-align: center; padding-bottom: 25px;"><span style="position: absolute; z-index: 11; padding: 5px 0px; bottom: 0px; left: 10px; font-size: 12px; color: black; background-color: transparent;"><?php the_title(); ?></span><a href="<?php echo do_shortcode('[ct id="_ct_text_4fd0e480b7623" property="title | description | value"]'); ?>" class="preview" title="<?php the_title(); ?>"><?php the_post_thumbnail('medium'); ?></a></li>
    <?php endwhile; // end of the loop. ?>

    So this calls the custom post and displays it in an un-ordered list. What I need is to give every post it’s own id so that I can style each one a little differently with css. Can someone please help! Thanks!!

  • The topic ‘Giving a different id to every list item’ is closed to new replies.