WordPress



WordPress 2.7 Comment Threading Howto


The new UI of 2.7 is nice and all, but what really amazed me was that the developers integrated comment threading, at least, if the theme supports it. So after a few tweaks and going through Otto’s article a number of times until I finally understood how it works, I was able to use the new feature in my theme.

The feature has been integrated in my theme since 2.7-Beta1 was released, yet only now did I realize that my reference was a bit too technical, even for me, that I decided to write another howto that is simplified. Before jumping in, I would highly advise to disable any comment threading plugin, including Disqus, to avoid any unwanted hiccups. Of course, the decision to do this is all up to you.

Still here? Then let’s begin.

There will be two files that needs editing. Three, if you want to release your theme and make it backwards-compatible. This howto is for those that are NOT going to make their theme backwards-compatible. In other words, the instructions on this page is for WordPress 2.7 and above only.

The files that need editing would be header.php and comments.php, both can be found in your theme folder.

In header.php, you would need to add a line between the <head></head> tags, preferably at the line right before the wp_head() function.

<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>

Simple, right? Right. In comments.php, however, it gets tricky. And a little bit dangerous. But not to worry. As long as you know how to read and compare codes, and with some patience, you’ll do just fine. But for safety’s sake, make sure you back up your comments.php file. All done? Good.

Open your comments.php file in your favorite text editor. Then, look for the line of code where you see

if ( have_comments() ) :

Below or after that, you would usually see the opening tag for a list <ul> or <ol> with a class of commentlist. To use the new threaded comments feature, anything in between the opening and closing tags of the list should be replaced with the following:

<?php wp_list_comments(); ?>

So your comments loop should look like this:

<ul class="commentlist">
<?php wp_list_comments(); ?>
</ul>

Then after that, you would need to add the following lines of code to enable paged comments, that is, if you enabled it in the Settings > Discussion page.

<div class="navigation">
<div class="alignleft"><?php previous_comments_link() ?></div>
<div class="alignright"><?php next_comments_link() ?></div>
</div>

So for the code that shows the comments, etc., the following is the resultant code:

<?php if ( have_comments() ) : ?>
<h3 class="tooltitle"><?php comments_number('No Replies', 'One Reply', '% Replies' );?> to "<?php the_title(); ?>"</h3>

<ol id="commentlist">
<?php wp_list_comments(); ?>
</ol>
<div class="navigation">
<div class="alignleft"><?php previous_comments_link() ?></div>
<div class="alignright"><?php next_comments_link() ?></div>
</div>
<?php else : // this is displayed if there are no comments so far ?>

<?php if ('open' == $post->comment_status) : ?>
<!-- If comments are open, but there are no comments. -->
<div class="tooltitle">No Replies to "<?php the_title(); ?>."</div>
<?php else : // comments are closed ?>
<!-- If comments are closed. -->
<div class="tooltitle">Comments are closed.</div>

<?php endif; ?>
<?php endif; ?>

Now, on to the form. The function we added in the header.php file actually makes it possible for the comment form to appear directly below the comment being replied to, but we need to make the form behave the way it is expected. The script looks for the id “respond,” so that’s what you look up in the form. Usually, it’s a place holder with an anchor tag like this: <a id="respond"></a>. It may sometimes appear in the comment form title:<h3 id="respond"><?php _e('Leave a Reply'); ?></h3>. All you have to do is remove that id and enclose the whole form in a div with the “respond” id. The form code is usually found after this line of code:

if ('open' == $post-> comment_status) :

So that’s what you look for first before enclosing the whole comment form in a div with id="respond".

<div id="respond">

--- Comment Form Code ---

</div>

The comment form code usually starts with the comment form title of “Leave a Reply” usually enclosed in <h3></h3> (e.g. <h3>Leave a Reply</h3>)

A line of code that lets you cancel your reply must be inserted just after the comment form title.

<div id="cancel-comment-reply">
<small><?php cancel_comment_reply_link(); ?></small>
</div>

And it should be before the line of code below:

<?php if ( get_option('comment_registration') && !$user_ID ) : ?>

Still with me? Good. Just one more line of code and you should be all set. This line of code makes it display two hidden inputs: comment_post_ID and comment_parent. Your comment form must have the comment_post_ID, so you have to remove it. Simply look for this line of code:

<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />

and replace it with

<?php comment_id_fields(); ?>

and you’re all done. Click here to see Otto’s live sample.

Save it and overwrite your comments.php file in your theme folder and you should have a working threaded comments section. If in case it doesn’t work, you did remember to make a backup of your comments.php file, right? So all you have to do is put it back in, overwriting the one you edited, and start over again.

You can post your questions in the comments section, and I’ll see what I can do. For styling questions, I would suggest you read Otto’s article. If in case you wanted me to check up on your comments.php file before you commit the changes, you can send it over to mail at will dot ph and I’ll review it for you for free, if time permits, that is.

Happy Hunting!

8 Comments »

WordPress 2.7 is now available!


Yesterday, December 10th, WordPress 2.7 RC2 was released, and a day later, which is today, December 11th, the stable version of 2.7 is finally released. A month overdue from it’s supposed release date, but the wait was well worth it. I have been following and testing the WordPress 2.7 since it’s pre-beta days, and I became a first-hand witness to the evolution of 2.7’s development. The transformation I witnessed was awesome, and I realize that I now regret not getting screenshots of each and every iteration that has become what it is today. The new administrative interface is more intuitive. The new features and functions the developers integrated is somewhat the answer of a typical users usual gripes.

Here are some screenshots that I managed to get before and after WordPress 2.7 was released.

In one word, spiffy.

SPIFFEH!

SPIFFEH!

Kudos to the WordPress Developers. This is truly one great milestone in the history of WordPress.

5 Comments »

WordPress 2.7 RC1


Here’s another quick post of a screenshot of the new Admin interface of WordPress 2.7 (currently RC1). It has two color schemes, gray and blue. Below is the blue theme, obviously. Heh. Choosing one or the other sports their own icons from the recently concluded WordPress Project Icon.

rc1

Final release is coming very, very soon.

Comments Off

WordPress 2.7 Beta 3 – 9889


Here’s a quick post of a screenshot of the new dashboard of the upcoming and much-awaited WordPress 2.7. The icons, they are new. And well-designed.

New Icons! Yay!

New Icons! Yay!

beta3-9889

I can definitely smell WordPress 2.7 RC1 in the air. And the final release is coming real soon. So far, it’s smelling very good.

Comments Off

WordPress 2.7 Beta 3

Cats: WordPress
Tags:

Here’s yet another screenshot of the new Dashboard of WordPress 2.7 (currently version Beta3-9791). And look, they used Verdana, my favorite font.

Screen fonts FTW!

Screen fonts FTW!

Comments Off

WordPress 2.7 Beta 2


Here’s a quick post of a screenshot of the new Dashboard of WordPress 2.7 Beta 2. It’s getting prettier everytime, but I think this is the last iteration of the aesthetics upgrade of the dash, that is, until they think of something else to change.

newdash

Comments Off

WordPress 2.7 Beta 1


So 2.7 is not bleeding anymore and WordPress developers have finally let the cat out of the bag. A lot of people have been testing it prior to its beta release, and most of the “complaints” are aesthetic-related. I know I’m guilty of some. I’m blaming Jane Wells for whetting my appetite for 2.7 when she posted a couple of articles showing screenshots and detailed descriptions of the new dashboard. But of course, I kid.

Now that Beta 1 is out, it is definitely time to give it a real test drive. I’m not talking about installing it on a subdomain and checking the new features out. I’m talking about real-world scenarios wherein a hundred people try to comment on one of your entries just to test the comment reply button and if it indeed threads comments, one of the new features 2.7 offers. Comment threading is theme-dependent, and it may be as simple as copying and pasting some code, but if you live to customize, it will NOT be a walk in the park.

commentform

Take for example, this site’s theme. Customizing the comment form alone gave me headaches for weeks. But I did learn a great deal when it comes to theme customizations and functions when using WP2.7’s built-in comment threading.

commentreply

The developers also beefed up a lot of the previously offered features. The Media Library is now more customizable. The Comments can be closed if an article is at a particular age. And you can control how deep threading comments will be, which has a maximum of 10 levels, for now.

mediasettings

commentsettings

The new interface, which is a far cry from 2.5, is really a hoot to work with. For me, it basically tells you what you want to know and gets out of the way for you to be more productive in producing your blog’s content. It’s more conducive to writing than before. In other words, I simply love it.

dashboard

Of course, using a beta version on a production blog is risky, and I know the risks involved. I simply had to do it for the sake of real-world testing and I want to see how it all pans out. I believe the only major hurdle the developers are trying to overcome are the aesthetics of the Dashboard, which is supposedly unfinished and needs a lot of work if you compare it to their target “look.”

Although WordPress won’t be able to release 2.7 on time (November 10th), the progress they show on an almost nightly basis is a glimpse of things to come. I surely can’t wait for 2.7 to be finally released as a stable version.

Cheers to the WordPress developers and their commitment to providing quality software.

P.S.
Comments found on the comments section of the Dashboard were from Ade, L.A., and Carlo. Please don’t sue me.

4 Comments »

WordPress 2.7-hemorrhage, Part 2


The latest feature that is finally working in WordPress 2.7’s development version is the automatic upgrade feature of the core files. Finally, I don’t have to download, extract, and FTP the files to upgrade my WordPress install.

Another thing I’m loving so far about this new version is the automated installation of the plugins found in the official WordPress Plugin Repository. So far, I haven’t run into any issues with it in the admin UI. Uploading a plugin from the admin UI is still in the works, though. I think they’ll be fashioning it after the media uploader. The only issue I have was with this one plugin that is no longer supported by its author: Download Counter. I have resolved to replacing it with another Download Manager and cleaned up my downloads, and got rid of files I no longer support, transferred to the Plugin/Theme repository, or stopped development. I haven’t upgraded this blog to the latest nightly, but I’m trying to make it as compatible to 2.7 as much as possible.

Automated theme installation from the repository is not yet implemented, nor have I seen any indicators about it being integrated, although if they were able to make the automated plugin installation work, it would only be a matter of time before it gets implemented.

My previous post also showed a new admin UI with the menu vertically oriented on the left side. It’s still on the same, but they revised it again. I’ll let the screenshots speak for itself.

Did I mention that comment threading functionality will be integrated to core? If I haven’t, then I just did. BUT the feature is theme-dependent. It’s up to the theme author to put in the support for this new feature. One of the reasons I won’t be releasing any more themes. For now. There’s a write-up for theme developers on how to make their themes compatible with the new comment feature. It’s quite a good read for theme developers. Beware of the amazon ad, though. It almost crashed Firefox. Make sure to read the comments as it gives insightful tips and tricks, too.

Utilities are gone, together with the Inbox. I still don’t know what it was for, and I’m kinda glad it’s gone. It’ll only add to the learning curve that is currently becoming steeper and steeper.

All in all, the new UI and the new and improved features being added to WordPress 2.7 will hopefully make the blogging experience more enjoyable as it lets you focus more on the blogging part and not the theme development part. WordPress may not be considered a CMS, but it sure is one heck of a blogging platform.

Comments Off

WordPress 2.7-hemorrhage


Out of sheer boredom, I decided to install and try out WordPress 2.7-hemorrhage, and so far, I like the changes made to the admin UI. The animated dropdown menus are quite smooth, but it takes some getting used to, with it being on the left side and is vertically oriented.

By default, the Content tree is expanded. This section is not quite new since it is just a renamed Manage page, but with more focus on content-related stuff. From here, you can manage Posts, Comments, Links, Pages, etc. The Media Library can also be found here. What I like about this section is that you don’t need a plugin anymore to quickly reply to a comment. I believe Ozh’s Absolute Comments plugin made it to core. This makes replying to comments A LOT easier. Also, the Quick Edit feature of the Posts page in this section lets you change the title, slug, date published, category, tags, and status without needing to edit the whole post. You can also make it a sticky post, but I believe this is dependent on the theme to be able to use this feature properly. Writing a new post has been improved, as the page is beefed up with settings that lets you display or not certain post properties. The tags and categories section is also moved to the right side of the post entry box. Finally.

Of course, the Dashboard is still there. It was revamped to show a posting area where you don’t have to go to the Write Post page. This makes for quick posting, hence the term “QuickPress.” There’s also an Inbox, which I don’t have an idea what it does except show comments from some post I have no idea what about. I’m guessing this is simply a placeholder for something the developers will be rolling out as a surprise. And I don’t think it has anything to do with email, but I’m suspecting it would be in line with showing comments from WordPress.com posts. It may be another use for the WordPress.com API.

The Design tab is replaced by the Themes section, which allows you to do the same things as before: browse the installed themes, manage widgets, and edit template files. It basically has the same features as 2.6, with the theme preview before activating the theme. However, the developers are planning to automate the addition or installation of new themes from the Directory page of the Themes section. It’s not yet implemented with the current nightly, and maybe added past 2.7, but it will surely make it there.

Managing categories, tags, users and user profiles, the Import and Export feature, and link categories are now in the Utilities section, with the addition of the Inbox. With my installation of this nightly, the Inbox is still not manageable. Nothing new here except the layout. The developers simply organized what can be managed into more sensible sections – Content for content-related stuff, and Utilities for content meta(?)-related stuff.

One other thing that really caught my eye and made me want to deploy it immediately to my photoblog is the new image management features added. With the current stable version of WordPress, you can manage your thumbnail- and medium-size maximum dimensions from the Miscellaneous page of the Settings section. With the upcoming release, still in the same page, you can also control the large-size maximum dimensions and set the default posting settings for the image size, image alignment, and image link. What I’m wishing the developers add to this is the ability to resize the existing images without having to re-upload them whenever you change one of the image size settings. Although far from being a photoblogging platform, these features, together with a photoblog-focused theme, would make a great alternative to other photoblogging or photo gallery platforms.

Although it’s all spiffy and such, 2.7-hemorrhage still has a lot of kinks to be worked out. The automated installation of plugins for one, and the Inbox, obviously. The automated installation of plugins does not quite work for me, although I was able to upgrade my plugins with a pre-2.7 install with no issues. I wonder if this will be addressed when the stable version is released come November. So far, this is the only issue I am having with 2.7-hemorrhage. Hopefully, the latest release will have all the features listed here fully functioning. And about the Inbox, it would be really helpful if there was more information about this new feature.

Another thing to look forward to is the automated upgrade of the WordPress install itself, though there are a lot of things that could go wrong here. It may be included in 2.7, but your mileage may vary. Nothing to do but to keep those fingers crossed.

I finally had a small taste of 2.7, and I am wanting more. I can’t wait to have this installed on my blog. When’s November coming?

6 Comments »

WordPress Theme Repository


Finally, the long wait is over. WordPress Theme developers can now upload their themes in the newly refurbished theme repository under the Extend umbrella. Knock yourself out, kids.

Comments Off