I’ve been working hard on a new WordPress theme, but I needed the theme to be compatible with both WordPress 2.6 and 2.7.
If you’re a theme developer, you already know how hard it’s going to be to make your 2.7 theme backward compatible because of all the new features being added.
I won’t go into the details of how to put together a comments.php file here. There are plenty of tutorials and themes to look at for that.
Check out Otto’s WordPress 2.7 comments enhancements tutorial to add all the extra features to your theme’s comments file.
Setting up the comment files
Let’s assume you start with a WordPress 2.6-ready comments file. What you need to do is save that file as legacy.comments.php in your theme directory.
Next, you need to create your WordPress 2.7-only comments file and save it as comments.php.
What we’ll be doing is checking the version of WordPress the theme user has installed. If they’re using 2.7, we’ll call comments.php. If they’re using 2.6 or below, we’ll use legacy.comments.php.
In your theme’s functions.php file, add this code:
<?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;
}
?>
That’s it. All we did was filter the comments_template.
So, if you’re looking to add a little backward compatibility to your WordPress theme, this should help a bit.
Thanks a lot!
Can you please share some of the other issues which must be kept in mind while working on themes that are both 2.6 and 2.7 compatible.
Thank you for your time.
This was the biggest issue. There are some things you can’t get around if you decide to use the new features as implemented in the Default theme, such as
post_class(). You’d have to implement your own function to replace it.The next big one would be
wp_page_menu()to list a navigation menu of pages. I’ll probably cover that in the next tutorial.That would be great!!
Thanks.
It looks like I’m going to have to start work on BoltPress 2.1’s code soon. I can’t bear to part with my really awesome 2.0 design so I’ll just recode it for WordPress 2.7.
I also have Thistle to worry about, and I’m not even sure about my Sandbox designs anymore :S
Just when I thought I was going to need long conditional tags. Thanks for this.
Great tip, Justin. Thank you very much.
WP2.7 messed many things from the front end (Theme) to the admin panel.
Wow, this is SO strange. This is almost EXACTLY the same method I employed 2 weeks ago to make a future free theme of mine 2.5-2.7 compatible.
Great minds think alike, eh?
That’s a pretty clever approach that I had not considered. Nice and clean.
BoltClock
I know what you mean with updating themes. I’ve got four other major themes that must be updated.
Lyndi
This will definitely cut back on all those conditional tags and
function_exists()checks. You’ll only have to use one conditional with this method.J Mehmett
Yeah, there are some major changes in 2.7 that have to be considered from both a frontend and backend perspective. Things are better, but there’ll be a lot of backward compatibility issues.
Nathan
I’m thinking they do think alike.
I’m actually making my theme 2.5 - 2.7 compatible but said 2.6 in the post for simplicity. Filters make WordPress such an easy platform to customize.
Otto
“Nice and clean” was exactly what I was going for. I had so many conditional tags it was starting to get ridiculous. After my
comments.phpfile soared up to over 7kb, I knew I needed a better method.[...] Making your theme’s comments compatible with WordPress 2.7 and earlier versions Good to know, what with the approaching release. [...]
[...] of the more interesting ways I’ve seen to use this is to have the “old comments” php in a separate file [...]
[...] Are you looking to make your WordPress installation compatible with WordPress 2.7? Justin Tadlock recently featured a great post explaining how to make your theme’s comments compatible with WordPress 2.7. [...]
Wow, thanks for sharing Justin.. it’s perfect
[...] survey regarding all the new features of WordPres 2.7, where you can provide additional feedback. - Make your themes comments compatible with WordPress 2.7 and earlier versions. - WordPress 2.7 Comments Enhancements: An in-depth post on the changes WordPress 2.7 brings to [...]
[...] In this latest release you will be able to have threaded and paged comments, like on Digg. Well, you got it by yourself, that means a bit of work for developers while adapting your own WordPress theme to the new comment system. Can you do that? Yes, thanks to the great tutorial by Otto! Justin Tadlock has also proposed us a method to create a WordPress 2.6 and 2.7 compatible theme! [...]
[...] Making your theme’s comments compatible with WordPress 2.7 and earlier versions (tags: obeertym) [...]
Jauhari
No problem. I’m hoping we can get most theme developers to update their comments for 2.7 but still allow for those users that upgrade a little later (you know, the [dot] 1 crowd).
Anyone wanna edit my theme? I’m clueless.
-Pat
Paleo Pat
You can use my contact form if you’re interested in hiring me to do any work on your theme.
[...] Making your theme’s comments compatible with WordPress 2.7 and earlier versions [...]
[...] Making your theme’s comments compatible with WordPress 2.7 and earlier versions.: If you are a theme designer or author, you need to know that your legacy theme’s comments page will not be compatible with WordPress 2.7 Justin Tadlock has written up a simple (and clean) procedure to make the comments page compatible with WordPress 2.7 and still be backwards compatible with slightly older version of WordPress. [...]
[...] manter o tema compatível com o 2.7 e com o 2.6 o bacana é ver este artigo. Já para entender as alterações necessárias no tema para usar o [...]
[...] Comment Template and the features it brings like Comment Paging, Comment Threading and even more.Make your Comment Templates 2.7 and backwards compatibleDetailed Post about adding the Comment [...]
[...] Making your theme’s comments compatible with WordPress 2.7 and earlier versions.: If you are a theme designer or author, you need to know that your legacy theme’s comments page will not be compatible with WordPress 2.7 Justin Tadlock has written up a simple (and clean) procedure to make the comments page compatible with WordPress 2.7 and still be backwards compatible with slightly older version of WordPress. [...]
[...] reference of how to enhance your comments file, from Justin Tadlock’s early preparation for 2.7 and Otto’s WordPress 2.7 Comments [...]
[...] Making your theme’s comments compatible with WordPress 2.7 and earlier versions.: If you are a theme designer or author, you need to know that your legacy theme’s comments page will not be compatible with WordPress 2.7 Justin Tadlock has written up a simple (and clean) procedure to make the comments page compatible with WordPress 2.7 and still be backwards compatible with slightly older version of WordPress. [...]
[...] I have been asked by many people if my Revolution themes will be updated to accommodate WordPress 2.7 and Threaded Comments. The answer is yes, with thanks to a few lattes, 2 1/2 hours and posts that I’ve read from Otto and Justin. [...]
[...] Tools Collection: Are your theme’s comments WordPress 2.7 compatible? Kas.08, 2008 in WP-RSS Making your theme’s comments compatible with WordPress 2.7 and earlier versions.: If you are a theme designer or author, you need to know that your legacy theme’s comments [...]
[...] Justin Tadlock - Making your theme’s comments compatible with WordPress 2.7 and earlier versions [...]
[...] Justin Tadlock - Making your theme’s comments compatible with WordPress 2.7 and earlier versions [...]
[...] Justin Tadlock - Making your theme’s comments compatible with WordPress 2.7 and earlier versions [...]
[...] to Justin Tadlock for this awesome [...]
[...] really nice information for themecreators or people who made their own theme can be found here at justintadlock.com and here at ottodestruct.com [...]
[...] Making your theme work in both 2.7 and other versions [...]
[...] survey regarding all the new features of WordPres 2.7, where you can provide additional feedback. - Make your themes comments compatible with WordPress 2.7 and earlier versions. - WordPress 2.7 Comments Enhancements: An in-depth post on the changes WordPress 2.7 brings to [...]
[...] Justin Tadlock - Making your theme’s comments compatible with WordPress 2.7 and earlier versions [...]
i want to share my free wordpress theme here.
Deleted by admin.
Yeah, posting links to your site in an inappropriate place is the quickest way to get them deleted.
顶~~~~我叫泉州生活网,希望能交个朋友哈!
[...] Justin Tadlock - Making your theme’s comments compatible with WordPress 2.7 and earlier versions [...]
[...] 原文:Making your theme’s comments compatible with WordPress 2.7 and earlier versions by [...]
[...] Justin Tadlock - Making your theme’s comments compatible with WordPress 2.7 and earlier versions [...]
[...] Justin Tadlock - Making your theme’s comments compatible with WordPress 2.7 and earlier versions [...]
What about the avrious themes that you offers?
[...] convient de préparer le changement de version pour son template. Justin Tadlock nous explique dans Making your theme’s comments compatible with WordPress 2.7 and earlier versions comment s’y préparer : par l’ajout tout simple d’une petite fonction de filtre [...]
Shanker
What do you want to know about the themes that I offer?
[...] 原文:Making your theme’s comments compatible with WordPress 2.7 and earlier versions by [...]
[...] troisième solution, proposée par Justin TadLock me semble la plus [...]
[...] http://justintadlock.com/archives/2008/11/01/making-your-themes-comments-compatible-with-wordpress-2... [...]
[...] My WordPress Theme Will Break: There is very little that will impact WordPress Themes in this new version, outside of WordPress Plugins that interact with WordPress Themes, especially with comments. WordPress Themes will be even better protected in future versions with the Parent/Child Theme feature (your changes are protected during upgrades) and easy auto-updating of Themes. If your Theme features customization to the comments area, see Migrating Plugins and Themes to 2.7 and Justin Tadlock’s “Making your theme’s comments compatible with WordPress 2.7 and earli…. [...]
[...] Justin Tadlock - Making your theme’s comments compatible with WordPress 2.7 and earlier versions [...]
[...] News: For information on the new structure of comments and trackbacks in WordPress 2.7, please see Justin Tadlock - Making your theme’s comments compatible with WordPress 2.7 and earlier versions and Sivel - Separating Pings from Comments in WordPress [...]
[...] My WordPress Theme Will Break: There is very little that will impact WordPress Themes in this new version, outside of WordPress Plugins that interact with WordPress Themes, especially with comments. WordPress Themes will be even better protected in future versions with the Parent/Child Theme feature (your changes are protected during upgrades) and easy auto-updating of Themes. If your Theme features customization to the comments area, see Migrating Plugins and Themes to 2.7 and Justin Tadlock’s “Making your theme’s comments compatible with WordPress 2.7 and earli…. [...]
[...] My WordPress Theme Will Break: There is very little that will impact WordPress Themes in this new version, outside of WordPress Plugins that interact with WordPress Themes, especially with comments. WordPress Themes will be even better protected in future versions with the Parent/Child Theme feature (your changes are protected during upgrades) and easy auto-updating of Themes. If your Theme features customization to the comments area, see Migrating Plugins and Themes to 2.7 and Justin Tadlock’s “Making your theme’s comments compatible with WordPress 2.7 and earlier versi…. [...]
[...] Making Your Theme Comments Compatble with 2.7 & Earlier Versions(让你主题兼容WordPress 2.7 和以往版本) Justin Tadlock 讨论的这个很好的话题,告诉我们如何让你的主题同时兼容 WordPresss 2.7,并能回溯兼容早期版本。适合主题开发者。 [...]
Thanks so much for this.
I’d like to second Mayur Somani’ request to please share also other issues which must be kept in mind while working on themes that are both 2.6 and 2.7 compatible.
Hello,
I have install wp 2.7 but the theme is not compatible with threaded comments and i add the up code in functions.php from theme and change from legacy.comments.php sin comments.php but i don t see a change in my post comments. What is wrong what i need to do more?
Thanks
Sarah — This is the major thing you have to watch out for. Check out the WordPress Codex for a complete list of changes.
dodo — This isn’t a tutorial on making threaded comments work. This is a tutorial for theme developers that want to add backward-compatible comments. You should go to the WordPress.org support forums if you need help setting yours up or ask your theme author.