you're reading:
Attachment pages, Galleries, Html & inline css codes, Next-page tag, Page splits, Previous/next tabs, Themes

Navigation tabs on gallery attachment pages
Update Oct.+Dec. 09: post obsolete (except tip at the end) – now almost all themes feature previous/next navigation links on gallery attachment pages.

One of the defects of the so-called gallery attachment pages is that in most themes you have to go back to the gallery post in order to click on another thumbnail. There are a few themes, however, in which attachment pages include previous/next navigation thumbnails:

DePo Masthead (below comment box)
DePo Square
Misty Look
Sandbox 1.6.1
Spring Loaded

For the rest, you can manually create such navigation tabs (if you don’t mind the awful chore it is):

1. For a text link, e.g. “Next”, the code would be:


For a thumbnail link instead of the text tab, the code would be:

<a href="URL_OF_NEXT_ATTACHMENT_PAGE_HERE"><img src="URL_OF_NEXT_IMAGE_HERE" height="60" /></a>

(The height number is a suggestion – you can change it. The URL of an attachment page is the post URL plus the image name as it shows up in the image URL, without the “.jpg” part, folllowed by a slash.)

2. You create these links, then create the following table code and paste it in the description box of the images:

<table width="100%">
<td align="left">LEFT_LINK_HERE</td>
<td align="right">RIGHT_LINK_HERE</td>

For the first and last images you can have a link with the appropriate text tab instead of “Previous” or “Next” (e.g. “Back to post”), or you can leave that part of the table code (the part shown in capitals) empty, if you want nothing instead.

The “100%” shown above is suitable for fixed-width themes and large images that will occupy the whole of the available post or page width. For flexible-width themes and/or smaller images, the first line of the above code should be:

<table width="NUMBERpx">

Where “number” is the width of the image (or around 10 larger than that, if the theme creates borders or frames around images).

Example here. [Update 26/10: messed up now that attachment pages automatically include navigation thumbnails.]

For a simpler alternative you can omit the table – just write this in the description boxes:

<div> </div>

This way you get both tabs aligned left, the one below the other. Less work to do; but less elegant.

Easier alternative: forget the gallery feature altogether, upload and insert independent images, and use page splits after each image (the “nextpage” tag – see here). This way you’ll get a series of pages with a series of number links below them. Example here (created after her question / my suggestion in the forum).


22 thoughts on “Navigation tabs on gallery attachment pages

  1. Brilliant

    Posted by Jonathan Martinez | April 18, 2009, 18:01
  2. Thanks! Do you mean the coding for the navigation tabs or the page-split alternative? If it’s the first, I must point out that the original idea wasn’t mine (see here) – I only refined it and worked out the details.

    Posted by Panos | April 19, 2009, 04:57
  3. That use of the “nextpage” tag is very clever. I hadn’t noticed that until now.

    Posted by Tess | May 11, 2009, 19:02
  4. Inspired by a question in the forum – as most things here!

    Posted by Panos | May 11, 2009, 22:49
  5. Ah, and it’s an update: wasn’t there when I first published the post.

    Posted by Panos | May 11, 2009, 22:51
  6. Hi Panos,
    Look at this:
    So now I just tried the gallery navigation with “unsleepable.” (test blog).
    More innovations at Or is this another case of me gliding by the details to miss the forrest?

    Posted by Tess | October 22, 2009, 01:23
  7. @Tess: Themes checked, post updated…

    Posted by Panos | October 26, 2009, 08:21
  8. Hi Panos!

    How many pages are possible using the tag, is there a limit?

    I want to create a page for guest speakers and have their audios on each page but how many is too much do you think.


    Posted by Lola | December 14, 2009, 05:51
  9. sorry I dont know what happen there, I had written ‘how many pages are possible to create using the ‘next’ tag’.


    Posted by Lola | December 14, 2009, 05:52
  10. @Lola: In theory there’s no limit. I haven’t tested it beyond three-digit numbers – hope that’s high enough for you!

    What happened in the first comment is that you pasted the actual code for the nextpage thingie. If you paste a code, the result won’t be what you pasted, it will be the effect the code is meant to produce. In comments, in particular, many codes don’t work, so they are automatically stripped out. The codes you can see all over my posts (occasionally in comments too) are written in a special way: for instance, to display the nextpage code, instead of the (functioning) bracket I’ll have to write the html that produces that bracket on the page – see “Html characters” and “Html converter” in my Links 2.

    Posted by Panos | December 14, 2009, 09:11
  11. Ok thanks Panos wow 3 digit numbers?? I should be so lucky! Thanks Im looking forward to trying it out

    And thanks for explaining. I thought I had lost my marbles for a moment lol

    Posted by Lola | December 15, 2009, 01:03
  12. Hi again its me Lola

    Does the next tag work on a page of wordpress audio players? Like if I have player 1, player 2 + 3 etc so I was trying to do one player per page


    when I tried it the page numbers appeared at the bottom of the first page with only one player, which is what I wanted but then when I clicked on the page number 2 it showed as a single page with all the audio players instead of player 2, and page numbers 3+4 .

    So Is this possible for audio players or have I done something incorrect?

    Thanks Panos for the help

    Posted by Lola | December 15, 2009, 09:41
  13. @Lola: Probably something incorrect! Can’t tell if I can’t see the page.

    Posted by Panos | December 15, 2009, 13:02
  14. lol That would be right!

    ok heres the html from when I edit the page, All i did was add the next tag I didnt alter anything else


    Posted by Lola | December 15, 2009, 13:17
  15. That’s no html! I need to see the actual published page, so I can check the source code. (But I won’t be able to answer soon – I’m off to work now.)

    Posted by Panos | December 15, 2009, 13:29
  16. oh haha!

    The page is already published its

    Is that what you mean? and no worries I’ll check in later Thanks!!!!

    Oh I out the page widget back on if it helps

    Posted by Lola | December 15, 2009, 13:39
  17. Ah, that page! I had seen it, but I thought you were talking about another one – didn’t notice you wrote wordpress audio players above. Well, a) there are no page splits in that page now, so I still can’t see what might have gone wrong, b) there should be no problem having page splits after each player: just make sure you paste the nextpage tags in the html editor, not the visual, and not after any other opening html tag.

    Posted by Panos | December 16, 2009, 00:27
  18. Yay it worked Thanks Panos! I couldnt edit the original page to get it to work but when I did it in a new page it worked great. Thank you for the help Now I can work on it how I wanted it originally I am happy!

    Posted by Lola | December 16, 2009, 05:51
  19. Hi,

    im new to php…

    where i have to add the code.. attachment page mean what file exactly .Please give the name

    Posted by Arun | January 10, 2011, 23:45
  20. Hi, but I cannot help. If you can edit your php files, you have a self-hosted blog. As my tagline says, my blog is about blogs: different software.

    Posted by Panos | January 11, 2011, 12:48


  1. Pingback: Not the Official Gallery FAQ « Random Acts of Photography - September 28, 2009


author's avatar panos (justpi)

 Subject Index

Announcement 22/03/2012: After WP's latest move, this blog will no longer offer active support and assistance. The blog will remain online but commenting on older posts has been disabled.
✶ All theme-related posts are updated up to and including theme 189 in this list, but will not continue to be updated.


  • Views per month:
Safari Icon Firefox - Never Internet Explorer
Note: if you see ads on this site, they are placed by WordPress, not me.
Mostly on themes, formatting, coding, tweaks and workarounds.
Based on or springing from my contributing in the forum.
Theme-related posts constantly updated
Premium themes and Annotum not included
%d bloggers like this: