Site icon Hip-Hop Website Design and Development

Rewrite image links from attachment id to attachment link

WordPress is having trouble writing links to attachment pages.

Sometimes an image links like this:
mysite.com/my-post/my-attachment-page

Othertimes an image links like this:
mysite.com/?attachment_id=xxxx

there’s no rhyme or reason to it. Images in the SAME gallery could link in two different ways.
I don’t know how to tell if the urls are staying consistent. If not, Google won’t like it much.

Is there a way to force images to link to the attachment page using the pretty link and not the id?