If you’re like me, you’ve recently upgraded to Wordpress 2.7. One of the great features of 2.7 is the built in threaded comments and comment paging features.

Good news

These comment treading features allow your visitors to reply directly to comments on posts instead at at the bottom of the list. You can control how many comments to nest, how many to show per page etc. It is a very powerful new feature.

Bad news

Unfortunately, if you are using a wordpress theme that was not developed specifically for Wordpress 2.7, then you cannot use the threaded comments features.

But with a few simple changes to your old wordpress theme, you can add the features in a snap.

How to do it

The Wordpress 2.7 default theme is in a directory called themes/default . Let’s say your theme is in a directory called themes/custom .

1. Copy your file themes/custom/comments.php to a new file called themes/custom/legacy.comments.php

2. Copy the new Wordpress 2.7 themes/default/comments.php file to your themes/custom/ directory. This will overwrite your old comments.php file but you have made a copy of it called legacy.comments.php

3. Edit your file themes/custom/functions.php and add the following lines to the top of the file:

<?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';
	endif;
	return $file;
}
?>

4. Click ‘enable treaded comments’ from the Wordpress 2.7 dashboard in the Settings > Discussion menu.

That’s it! View one of your posts which has comments on it and you will see a “Reply” link below each comment. Click the link to write your very own treaded comments.

As a side note, these changes allow your theme to be backward compatible with older 2.x versions of Wordpress so if you downgrade your Wordpress from 2.7 or use the same theme on multiple versions of Wordpress, then your comments.php will still work with older versions.

[Make sure you backup the files mentioned in this post before making any changes to them]

Share

2 Responses to “Get Wordpress 2.7 threaded comments on your old theme”

  1. Conor Neu says:

    This is very helpful, thank you. Will be implementing this on a few of our sites shortly.

    Glad to see you posting again, Richard. I’ve found your articles to be incredibly helpful.