With the release of Wordpress 2.1, I wonder whether I should drop support for WP2.0 and build future themes for the new version. Maintaining 2 set of files can be rather bothersome but I believe many may not switch over to WP2.1 so soon. Maybe I should wait for a few months when the dust settle down, but wait.. WP 2.2 would be launched by then.. duh..

Fear not.. borrowing the code from Wordpress Widgets, we can determine which version of WP is running and run the appropriate code. I’m not sure if this is the most efficient way, with if/else statements all over the place. Feel free to share if you know of better methods. So here goes..

In /wp-content/yourtheme/functions.php, add the following code.
The wp_version() function will return 20 if WP2.0 and 21 if WP2.1

function wp_version() {
global $wp_db_version;
if ( $wp_db_version > 3582 ) {
return '20';
} else {
return '21';
}
}

Using wp_version(), we can choose what to display in the theme. Example as below:

In header.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php if (wp_version()=='21') language_attributes(); ?>>

In sidebar.php

<?php if (wp_version()=='20') { get_links_list(); } else { wp_list_bookmarks() } ?>

To see which template tags are affected, you can refer to my short list.


What's Next?

» Share This (Social Bookmarks/Email)
» Subscribe to Feed
» Subscribe to Email
» Leave a Comment

Related Posts:
» Minor Update of Themes to Version 1.1
» Top 8 Wordpress Theme Directories
» WP Theme: GenkiTheme (Fixed Width)

» Newer Post: Minor Update of Themes to Version 1.1
« Previous Post: Migrating Your Wordpress 2.0 themes over to Wordpress 2.1