WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am almost completely happy with a new site I built - see http://www.fatasbutter.com.au/gallery/the-music/attachment/019/

As a final touch, I want to add #content to the end of the link location for each previous_image_link() and next_image_link().

Any ideas on how to do this?

share|improve this question
up vote 1 down vote accepted

This is kinda dirty, but I can't find a better hook:

function add_content_hash( $link ) { 
    $link = str_replace("' title='", "#content' title='", $link);
    return $link;
add_filter( 'wp_get_attachment_link', 'add_content_hash' );
share|improve this answer
Perfect. Thank you! – David John Smith Oct 26 '10 at 2:17

For now I have included simple jQuery to tack #content on the end of the links:

$('#nav-below a,.attachment a').attr('href', function() {
  return this.href + '#content'

Obviously javascript is not a 100% solution, but it's certainly the simplest (only?) option at this point.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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