How to number each output with a link?
-
Overall what I’m trying to do is list the number of attachments (1, 2, etc) for each post on a page. When you click on a number, it will change the image. Pretty much like a slideshow. How would I go about adding the numbers in my loop or could this be better solved via jQuery?
Code (so far):
<?php if( function_exists( 'attachments_get_attachments' ) ) { $attachments = attachments_get_attachments(); $total_attachments = count( $attachments ); if( $total_attachments ) : ?> <ul class="process"> <?php for( $i=0; $i<$total_attachments; $i++ ) : ?> <li><a href="<?php echo $attachments[$i]['location']; ?>"></a></li> <?php endfor; ?> </ul> <?php endif; ?> <?php } ?>
Desired Output (in view source HTML):
<li><a href="https://domain.com/path/to/image1.png">1</a></li> <li><a href="https://domain.com/path/to/image2.png">2</a></li> <li><a href="https://domain.com/path/to/image3.png">3</a></li>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to number each output with a link?’ is closed to new replies.