How to Add Jetpack Comments in a WordPress Theme

If you are aware of JetPack from WordPress, you must be also aware about the new comment form they introduced in one of the Jetpack extras which integrates Facebook, Twitter & WordPress integration along with the standard form of comment box.  This is what it will look like if somebody who is not logged into your WordPress blog which has Jetpack Comments Enabled (Download from here) :

Jetpack Comment Form


Now many of the WordPress blogs did not get this template even though it says it will automatically make it appear. So getting straight to the point, The problem is with the implementation of comments.php or the default implementation of the comment template  in most of the WordPress Themes.

The standard comment form in a theme has the following typical implementation :

  • Display Comments & Pingbacks.
  • Checks for User Information (Logged in etc) and finds details about it.
  • Checks if the comment form is open or closed etc.
  • If open, it adds the threaded reply system and so on.

What does Jetpack Comments look for ?

It looks for a hook or function called as comment_form() where it adds this new implementation. This was introduced in WordPress 3.0 and seems like many of the WordPress  Theme designer do not take advantage of this new function which is capable of doing all the things typically implemented in the comment section except Displaying Comments. Like the function name suggest, it is a Comment Form Generator.

If you are a developer you can take a look at the code of the function at this source which does the following things :

  • Find user Identity
  • Find current user
  • Make sure the required fields are marked.
  • Check if registration is required.
  • Support Threaded Reply.

This new Jetpack Function adds new fields to this function, and it works flawlessly.

How to modify Existing Comments.php to use this new function ?

If you are a developer you already know what has to go away, but if you want to do it on your own, here is what you need to.

  • Go to Appearance > Theme Editor
  • Open your comments.php form, and take a backup of this into a notepad or wherever you want.
  • Next, you need to find a section on the file which typically has the code for generating comment form. It should read like

<?php if (‘open’ == $post->comment_status) : or if ( ! comments_open() ) :

  • Mostly the comment form is generated after that. In this statement you will all input text, submit button etc generated.
  • What you need to do next is delete everything inside that IF Statement and replace it with comment_form function. So your form should look like now is

Comment Form Implementation in WordPress Comments

Done that you should be good enough to have the new comment form of WordPress 3.0 which is cleaner and If you have Jetpack, you will see it exactly as the image you saw on the top.

I will also suggest you to take a look at the WordPress Codex of this new form, if you prefer to modify it a bit. For example, you can :

  • Add a custom message before the required fields like Email, Name etc.
  • Change Title of the Comment form
  • Change Label of Submit Button

Hope this post has helped you to implement the new comment form and the Jetback Comments as well. I will strongly urge Theme developers to make use of this form and help users get a cleaner code.


Please enter your comment!
Please enter your name here