Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am almost completely happy with a new site I built - see

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

2 Answers 2

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.