How To Create image.php Template File For WordPress Theme To Display Photo Gallery?
The benefit of image gallery is definitely meant to bring new experience of reading WordPress powered blogs, in term of presentation as well as loading speed of the pages that are rich of photos (since only image that is interested by the reader will be clicked and rendered in high resolution).
Although every WordPress themes that are working properly before release of WordPress 2.5 will continue to work after the upgrade, a new template file named as image.php should be created (if there is no one currently) in order to make full use of image gallery feature.
For example, when there is no image.php template file, WordPress automatically use single.php template file to present the medium-size photo, as shown in this screenshot:

When there is an image.php template file that makes use of WordPress image gallery functions, the photo gallery navigation looks more attractive and intuitive, where two hyperlinked thumbnails of next and previous image in relative to current medium-size picture are shown:

So, How to create an image.php template file for WordPress theme if there is no one currently?
The simple way to create image.php template file is to duplicate single.php as image.php and exercise these steps:
1) Open image.php with your favourite text editor,
2) Locate and remove the_content() function call with these “previous and next image link” functions:
3) Replace the_title() function call with this line to show the post permalink of photo gallery:
If you still can’t figure out how to do this, just simply make a comparison on single.php and image.php template files of the default WordPress theme that bundled with each release of WordPress core installation package.

For example, when there is no image.php template file, WordPress automatically use single.php template file to present the medium-size photo, as shown in this screenshot:

When there is an image.php template file that makes use of WordPress image gallery functions, the photo gallery navigation looks more attractive and intuitive, where two hyperlinked thumbnails of next and previous image in relative to current medium-size picture are shown:

So, How to create an image.php template file for WordPress theme if there is no one currently?
The simple way to create image.php template file is to duplicate single.php as image.php and exercise these steps:
1) Open image.php with your favourite text editor,
2) Locate and remove the_content() function call with these “previous and next image link” functions:
<div style="float:right;"><?php next_image_link() ?></div><?php previous_image_link() ?><br />
<div style="text-align: center;"><a href="<?php echo wp_get_attachment_url($post->ID); ?>"><?php echo wp_get_attachment_image( $post->ID, 'medium' ); ?></a></div>
<?php if ( !empty($post->post_excerpt) ) the_excerpt(); ?><br />
3) Replace the_title() function call with this line to show the post permalink of photo gallery:
<a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?> </a>
If you still can’t figure out how to do this, just simply make a comparison on single.php and image.php template files of the default WordPress theme that bundled with each release of WordPress core installation package.
Custom Search







2010 •
[...] Shortbread – The best of Scotland Steps: First, create a image.php template file if your WordPress theme doesn’t have one. As shown in my previous post, it is easy to create [...]
Thank you very much, your guide is pretty straightforward and work like a charm!
Do you know how long i’ve been looking for somerthing like this? A day
+. Thank you for this. Thank you.