How to Add WordPress 2.5 Gallery to Your Current Theme

Note: If you are a chinese user, you can get the Chinese version of this post here: 让您当前的主题支持 WordPress 2.5 的相册功能

The Great WordPress 2.5 given us so many new features. One of them is Gallery. And when you insert a gallery into a post and click a image of them, it will show 3 image on the page ("Previous image Thumbnail", "Current image", "Next image Thumbnail") insteat the "Single image" like before.

Of course, it is just to display like that in the default theme (Right now Sandbox and K2 also could do this). Because of so many reason, the theme you are using, maybe can't do that. Waiting for the Theme's Designer?? Forget it. It is so easy to do that, do it yourself.

In this post, I will make the default theme like a example.

Compare the theme between 2.3.3 and 2.5. You will find out that there was a new file "image.php". Right, this is the file to implement the effects. In this file, you can see some code like this:

<a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a> » <?php the_title(); ?>

Action: Display tittles of the image and the post

Effect: Post Tittle » Attachment Tittle

<?php if ( !empty($post->post_excerpt) ) the_excerpt(); ?>

Action: Display the caption of the image

<?php the_content(); ?>

Action: Display the description of the image

<?php previous_image_link() ?>

Action: Display the thumbnail of the previous image

<?php next_image_link() ?>

Action: Display the thumbnail of the next image

Actually, the codes upper can display everything just like the default theme. But you must put theme in the "image.php" file. It was not a image.php file in your current theme folder? Don't worry. "Single.php", "attachment.php" and "image.php" were so similar. So you can choose one of theme to given a edit. But, just remember that, DO NOT edit the original file, you should make a copy of the file and rename it to "image.php". Otherwise the theme will not work fine in the previous WordPress release.

Well, almost done. Tell you a easy way to do all of those. Copy the "image.php" of the default theme to your current theme folder. And edit the CSS file or edit the "image.php" file to correct the code. These will need you have some programming ability.

I used my fucking english to wrote down this post. It maybe has so many grammar error. So if you understand what I said, and you would help me, please leave a massage and tell me the error both contents and grammar.

Thank you everybody.

This entry was posted in WordPress and tagged . Bookmark the permalink. Follow any comments here with the RSS feed for this post.

Leave a Reply

Your email is never published nor shared. Required fields are marked *

*

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>