Add Previous & Next Image Pagination Links To Image Attachments

If you insert multiple images into a single post, you might want to add pagination so your readers can click thru each image.

The PHP code in this tutorial can be added to the end of your child themes functions.php file to create next and previous image links on image attachment pages only.

attachment settings

When you insert your images, you will need to set the attachment page settings for each image.

Change the genesis_entry_footer hook to loop_start, loop_end or any theme specific action hook if not using Genesis.

For translation, swap out the $text_domain in the code with your themes text domain.

Other Options

Alternatively, you could hard code the links in your image.php or attachment.php file directly using this code.

Note: Your images need to be uploaded and attached to a single post using the attachment page settings for the pagination links to work.

Related Tutorials