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.
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.
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.Wow, thanks for sharing Justin.. it’s perfect
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.
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.
顶~~~~我叫泉州生活网,希望能交个朋友哈!
What about the avrious themes that you offers?
Shanker
What do you want to know about the themes that I offer?
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.
Quite simple and useful, thanks a lot.
nice thanks man….
lahorimela
and do you know how to make threaded comments visible and “answerable” in the comments pop window???
0p0 — I don’t think
wp_list_comments()works incomments-popup.php. I don’t know why. I’ve tried without success.yeah… I opened a thread about it in the codex forum. If you find a way let me know, I hate threaded comments do not show up in the popup
Thanks for your answer
by the way the thread is this one
http://wordpress.org/support/topic/256848?replies=1
lets see if someone know of a way to resolve it
Cheers!
0p0
Hi,
currently I’m working on some modifications on a blog. The blog is based on WP2.7 and has a custom theme, made by somebody else.
Now I’m trying to get the threaded comments feature working, and I’ve used your tutorial but it isn’t working. I’ve added the line to the header.php file and the lines in the comments.php file, but it’s still not working.
An example can be found here: http://www.software-innovators.nl/2009/03/29/het-nut-van-pauzes/
Could you take a look at the source code of that page, please? Maybe you can find what is wrong with the structure or something? The blog’s content is Dutch, but the HTML page structure is English.
Kind regards,
Laurens — This tutorial works perfectly fine. I can tell from your comment that you did not really read it because it has absolutely nothing to do with making threaded comments. Nothing at all.
You should ask your theme creator to implement threaded comments or check out one of the many tutorials around the Web on how to do this.
You are right about me not really reading your tutorial. I think I mixed you up with somebody else while browsing through several tutorials.
The tutorial I actually meant was this one:
http://ottodestruct.com/blog/2008/09/29/wordpress-27-comments-enhancements/
Further advice is still welcome of course!
@Laurens.
You have double “respond” id, ids are meant to be used only once in a page render. I suggest you take out the id respond from the
, the last thing to have threads working 100% is to have a “cancel comment” link buit in WP by adding this tag to the end of the comment form, inside of it:http://codex.wordpress.org/Template_Tags/cancel_comment_reply_link
I hope it is useful info
remove “respond” id ***from the h3 tag***
all you need to have threaded comments on 100% + the “cancel comment” link issued above:
http://codex.wordpress.org/Migrating_Plugins_and_Themes_to_2.7/Enhanced_Comment_Display
“Adsense Treasure” Review:
Wow, this one blew me away. What you get is a ready made website. The website runs automatically, you never have to maintain it or pay monthly hosting fees. I got one and it’s been bringing in around $1000 month for me. I absolutely love it.
I give Adsense Treasure a score of 5/5 (5 out of 5)
Click below for more info, check out his Porsche:
http://abid.in/paypal/?e=cyberprofessional
thank you, I’m using a theme made for 2.5 and just edited the code, worked like a charm!
i use 2.9.1 there is an error
Thank you very much for this. As said, could you share also other issues which must be kept in mind while working on themes that are both 2.6 and 2.7 compatible. Thanks
this information came in handy with the theme we were working on by now.
thank you very much.