WordPress.org

Support

If Next Image

  • I’ve been working with WordPress’ built in gallery feature and have back/next buttons below the individual attachment pages/images, but the problem I am having is when I am at the first or last image in the gallery and there isn’t a previous or next image, the button disappears. I tried the code below, but I don’t think the get_next_post is right, it should be something else like if_there_is_another_attachment_in_your_wp_gallery_blah

    <?php
    
        if ( get_next_post() ) {
    
           next_image_link( false, '<img src="/next.jpg">' );
    
       } else {
    
          next_image_link( false, '<img src="/next.jpg">' );
    
       };
    ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘If Next Image’ is closed to new replies.