I am confused about the exact purpose attachment.php ( and image.php) . I notice many themes dont have them. If single.php displays the image the way I want then is it OK to leave it out. On the other hand could i just make a copy of single.php for attachment.php and leave out the sidebar.

The other thing that confuses me is that when I add a gallery to a post I get the option to open images in an attachment page but when I add a single image to a post it only gives me the option to open the image as an image file (outside of the theme - ie without menus etc). I cant understand the point of this. What is the point in having an attachment.php file for images (or an image.php file) if it isn't going to get invoked when someone clicks on an image.

Ideally what i need is a good tutorial on attachments but I cant find any and i can find very little info in the codex.


1 Answer 1


This is part of the WordPress template system, it allows you to drill down and further customize output based in the template hierarchy, for instance if you want the attachments to have separate functionality/style then your single.php, you simply create attachment.php or go even further with MIME_type.php (like images).


Also you have 4 url options when inserting single images: custom url, file, post or none

enter image description here

  • Thanks,I think i may have missed something.But having looked at it again I think my confusion arises from there being different options available on edit than on insert. You correctly point out the insert options but when editing the options appear as: custom, image, CURRENT or none. Surely this means that the only way to have an existing image open in an attachment page, unless it's url was originally set to 'post' i guess as maybe the 'current' setting retrieves this, is to take it out and put it back in again. Would you agree; or is there a way to work out the post setting for a media. Commented Sep 13, 2011 at 17:50
  • .... further to this i actually discovered that taking the file extension off the end of the image url ( in my case anyway ) gives the post url which causes the image to open in single, index or the various attachment templates as explained above. I haven't bothered to check what happens when we have image.png, image.jpg etc in the same blog post Commented Sep 13, 2011 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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