Although in-line images and other media can be great in some circumstances, sometimes you really want to be able to highlight the importance of an attachment by placing the item on its own page and linking to it. Luckily, WordPress has support for attachment templates, allowing you to emphasize attachments appropriately.
The only requirement for this recipe is that you are working on a modern WordPress theme that works with WordPress 2.8 or 2.9.
First, we need to create the attachment template. The basic attachment template that we are going to create must be called attachment.php
. This template will be used to serve all attachment links.
Open attachment.php
, and insert the following template code:
<html> <head> <title><?php the_title(); ?></title> </head> <body> <?php $meta = wp_get_attachment_metadata($post->ID); $size = 'medium'; ?> <div style="margin: 0 auto; width: <?php echo...