WordPress Attachment Page Template Code Snippets
I haven't written as many WordPress tutorials as usual lately, as I have been so busy building websites and blogs, so I thought I would take the time out to share a few WordPress codes I have developed recently for attachment page templates and specifically the image attachment page template. The attachment page template is the page that displays a single image when the images link URL is set to 'Post URL'. You can set the image's link URL when inserting a single image into a post, and also when using the gallery shortcode.
The codes in this article are mostly applicable to images inserted using the gallery shortcode as they are most useful for posts or pages that have multiple image attachments. Read more about using image and file attachments.
These template codes can be added to your WordPress theme using the attachment.php and image.php files. If these template files do not exist in your theme you can create them, or WordPress will default to using single.php or index.php to show attachments by default. (See more about template hierarchy).
If you don't want to create a seperate image.php or attachment.php template you can always edit the index.php or single.php files and wrap the attachment specific codes in the is_attachment clause like so:
if(is_attachment()){
//attachment page specific code goes here
}
These php functions are loosely based on code I found in this article: Adding text links to WordPress Gallery by Michael Fields. In this article he provides code examples of how to show previous and next thumbnail links in a WP attachment page. I also made use of this previous-next keys in array function which is infinitely useful!
My first set of functions will return text links for previous image, next image and back to gallery. The functions themselves will need to be added to your theme's functions.php file before calling them in your image.php or attachment.php files. So here we go:
Read on…











Please how do I just rotate a simple circle in flash on mouse over and stop on mouse away.
Hi Lynette
I don’t see how this question relates to this article, but:
1. Draw a circle
2. Convert your circle to a button
3. Create a keyframe on the over state of the button
4.select the circle in the over keyframe and covert it to a movie clip.
5. edit the movie clip to include a motion tween
6. on the first frame of the motion tween edit the frames properties - setting rotation to either clock-wise or counter clock-wise