Variable class

0

I have a content loop in Wordpress and within that loop I posted a gallery (also WP standard):

<?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
    <?php endwhile; ?>
<?php endif; ?>

That generates the following HTML:

<dl class="gallery-item">
    <dt class="portrait">
        <img src=".../foto03-150x150.jpg" class="attachment-thumbnail">
    </dt>
</dl>
<dl class="gallery-item">
    ...
</dl>

The gallery has 11 images, so I need each of them to have a specific class. Eg: Where class="gallery-item" is written I need to be class="gallery-item1" , class="gallery-item2" and so on.

    
asked by anonymous 27.04.2014 / 19:12

1 answer

1

In the /wp-includes/media.php file, search for this snippet:

$output .= "<{$itemtag} class='gallery-item'>";
$output .= "
    <{$icontag} class='gallery-icon {$orientation}'>
        $image_output
    </{$icontag}>";

And add -{$id} to the end of the class noma. This way:

$output .= "<{$itemtag} class='gallery-item'>";
$output .= "
    <{$icontag} class='gallery-icon-{$id} {$orientation}'>
        $image_output
    </{$icontag}>";

This causes the position of the image in the gallery to be used in the class name.

    
27.04.2014 / 19:35