0

I'm using previous_image_link() and next_image_link() to show thumbnails in my image.php template page.

I'm surrounding the thumbs with some styling, so need to be able to hide the whole previous image thumb/link block when showing the first attachment.. and the same for the next image link/thumb when displaying the last one.

How can I ascertain whether a first or last image is being displayed using core functions?

(at the moment I'm using a modified version of adjacent_image_link() that returns not echo's the gubbins, but would like a non-hacky way)

1 Answer 1

0

Use the string function instead, and print it only if you get something:

$previous = adjacent_image_link(true, 'thumbnail' );

if ( ! empty ( $previous ) )
    print 'before' . $previous . 'after';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.