Grow your CSS skills. Land your dream job.

Using Last Class in NextGEN Gallery

  • # August 31, 2011 at 3:30 pm

    I’m trying to add a “last” class on the end of every fourth thumbnail for styling.

    Here’s the code:

    Any help would be appreciated.

    Thanks in advance.

    # December 12, 2012 at 8:35 am

    Put this in your gallery-caption.php


    < ?php
    $count = 0;
    ?>


    < ?php foreach ( $images as $image ) : ?>
    pid ?>" class="ngg-gallery-thumbnail-box" < ?php echo $image->style ?> >
    " > imageURL ?>" title="< ?php echo $image->description ?>" < ?php echo $image->thumbcode ?> > < ?php if ( !$image->hidden ) { ?> alttext ?>" alt="< ?php echo $image->alttext ?>" src="< ?php echo $image->thumbnailURL ?>" < ?php echo $image->size ?> /> < ?php } ?> < ?php echo $image->caption ?>
    < ?php if ( $image->hidden ) continue; ?>
    < ?php if ( $gallery->columns > 0 && ++$i % $gallery->columns == 0 ) { ?>


    < ?php } ?>
    < ?php $count++; ?>
    < ?php endforeach; ?>
    # December 12, 2012 at 8:41 am

    or just use

    < ?php
    $count = 0;
    ?>


    < ?php foreach ( $images as $image ) : ?>

    And this is your class:

     id="< ?php if ($count % 4 == 0) { echo "last"; } ?>" 

    and this

     

    < ?php } ?>

    < ?php
    $count++;
    ?>

    < ?php endforeach; ?>
    # December 12, 2012 at 8:55 am

    That seems complicated. Can’t you use nth-of-type?

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".