Post updated to use “Double Quotes” instead of Single Quotes, after realizing single quotes turn to apostrophe and causes the code to break.
I upgraded most of my popular themes to make sure they work with the latest WordPress release 2.3.
For anyone who is starting their blog right now, they can just install the WordPress 2.3 [and some plugins if they are privacy conscious] and start using one of my upgraded themes.
but there are people who have customized the theme so much, that they do not want to upgrade their theme with my latest version.
They want to know what exactly I changed for making theme WordPress 2.3 compatible.
The new feature that is added in the WordPress 2.3 system is the Tags functionality.
Once you upgrade your WordPress installation to 2.3, you would see a text box under the ‘Write Post’ area, for adding “tags” to both new and existing posts. This will let you store the tags along with the posts in the database.
Step 1: Display the Tags under each post’s content
Add the following code somewhere after the call to the_content() or the_excerpt() within “the loop” in index.php, archive.php, search.php and single.php.
<p><?php if (function_exists("the_tags")) the_tags("Tags: ", ", ", "<br/>");?></p>
This code makes sure the function "the_tags()" exists, before calling that. This way the theme will still work on earlier versions of WordPress.
One Important thing to Note:
the_tags() method will only work, when you made a call to the_post() method while initializing the loop.
Some themes still use start_wp() method instead of the_post(). Those themes will not show the Tags at all, even when you made a call to the_tags().
Step 2: Display a Tag Cloud on the Sidebar
If your theme is Sidebar Widgets Compatible and you are using the Sidebar Widgets option, you could easily drag and drop the Tag Cloud Widget [that comes with WordPress 2.3] and be done with it.
If not, you can add the following code somewhere in the sidebar.php file.
<?php if (function_exists("wp_tag_cloud")) { ?>
<li>
<h2><?php _e("Tags"); ?></h2>
<p>
<?php wp_tag_cloud(); ?>
</p>
</li>
<?php } ?>
Again, this code checks for the existence of the method, before calling it, just to make sure the theme works fine in previous versions of WordPress.
I think we have covered two important steps so far.
When someone clicks on one of the Tags, it will lead them to an archive page [WordPress loads the archive.php if found within the theme folder].
So we will just add a heading for the Archive page to let them know they are viewing the archives for that given Tag.
We will open up the archive.php. Usually there will be code that checks if this is an archive for category, or month or day etc.
We will add the following lines to it.
<?php if (function_exists("is_tag")&& is_tag()) { ?>
<h2>Archive for the Tag "<?php echo single_tag_title(); ?>"</h2>
<?php } ?>
This will just add a heading in case someone is viewing your archive by Tags.
Wow. Thats it?
Yeah, and your site is now ready to Rock and Roll with WordPress 2.3.
Disclaimer :
While I made sure the code given here works fine with my themes, there is no guarantee that this will work with your theme without any issues. If you do have an issue, doing it manually, please contact your theme author.
Do not post it as a comment here. Thanks.