DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Some days ago, I shown you how to make your comments template compatible with WordPress 2.7. If you’re a theme designer, you’ll probably be interrested to know how to ensure backward compatibility with older versions.

To achieve this recipe, you’ll need two file: The first one is a WordPress 2.7 compatible comments file, named comments.php. The second one is a comment template for older WordPress versions, named legacy.comments.php in this exemple.

Paste this elegant code in your theme functions.php file. Create this file if it do not exists yet. If the wp_list_comments() function doesn’t exists, the code will automatically load legacy.comments.php instead of comments.php.

add_filter('comments_template', 'legacy_comments');

function legacy_comments($file) {
	if(!function_exists('wp_list_comments')) : // WP 2.7-only check
		$file = TEMPLATEPATH.'/legacy.comments.php';
	return $file;

Thanks to Justin Tadlock for this awesome code.

Leave a Comment

Your email address will not be published. Required fields are marked *