How to test if there are no more previous or next image on attachment page?
You need to use the adjacent image link filters, defined in the source of adjacent_image_link() function. Example: add_filter( “next_image_link”, “cyb_next_image_link”, 10, 4 ); function cyb_next_image_link( $output, $attachment_id, $size, $text ) { if( $output == ” ) { return ‘<div class=”next-image”><span>NEXT</span> <i class=”fa fa-angle-right”></i></div>’; } return $output; } add_filter( “previous_image_link”, “cyb_previous_image_link”, 10, 4 ); function cyb_previous_image_link( … Read more