Google+ Comments for WordPress Plugin

google-plus-commentsFor many years now Facebook has had a very popular login feature and also offered the ability to easily integrate blog comments using your Facebook account. These options have proven to be very popular with all types of webmasters as they provide several convenient features and also help to discourage spammy or anonymous comments.

It always surprised me that Google wasn’t in this game, but the introduction of Google+ seems to offer Google the ability to offer these features to webmasters and be the ones collecting this information.  According to reports, apps that support Google’s login are now getting favorable search treatment and Google is starting to really push this feature.  Then last month, Google announced that Google+ comment integration is now available for Blogger users. So, what about WordPress users?

Not long after the Blogger integration was announced, the necessary code was discovered to do this manually using the following code:

HTML:

<script src="https://apis.google.com/js/plusone.js">
</script>
<g:comments
    href="[URL]"
    width="642"
    first_party_property="BLOGGER"
    view_type="FILTERED_POSTMOD">
</g:comments>

Valid HTML5 version:

<script src="https://apis.google.com/js/plusone.js">
</script>
<div
    data-href="[URL]"
    data-width="642"
    data-first_party_property="BLOGGER"
    data-view_type="FILTERED_POSTMOD">
</div>

Comments counter HTML (replaces < g:comments >):

<g:commentcount href="[URL]"></g:commentcount>

Valid HTML5 version (replaces < div >):

<div data-href="[URL]"></div>

Replace ‘[URL]’ with the URL of your web page and fit the ‘width’.

Link your web page to your Google+ profile to verify authorship.

Dynamic Google+ Comments HTML:

<div id="comments"></div>
<script>
gapi.comments.render('comments', {
    href: window.location,
    width: '624',
    first_party_property: 'BLOGGER',
    view_type: 'FILTERED_POSTMOD'
});
</script>

Google+ Comments Counter:

<div id="commentscounter"></div>
<script>
gapi.commentcount.render('commentscounter', {
    href: window.location
});
</script>

Google+ Comments for WordPress Plugin

Fortunately, the WordPress community has already come through with an easier solution, the Google+ Comments for WordPress plugin. This plugin makes the comment section tabbed by seamlessly adding tabs for Google+ Comments, Facebook, Disqus, WordPress Comments, and Trackbacks. Early reviews are promising and I manage this plugin will continue to evolve over time.

If you decide to give this plugin on your website leave us a comment and let us know how the setup went.

  • Leave a Comment
  • Collection of WordPress Comment Hacks

    There are all sorts of WordPress hacks people can easily do to customize and improve both the look and functionality of their WordPress blog, but I’ve always felt that the comments section is one of the best ways to truly customize your WordPress theme.   After all, blogging is all about author interaction, and the comments go a long way towards conversations happening.

    If you are looking to improve the comments field of your blog’s theme, Instant Shift recently took the time to feature a number of comment hacks, which can be viewed here.   Looks like they’ve already got 30 hacks included, including a few we’ve featured here in the past.

  • Leave a Comment
  • Which Plugins Do You Want to See Built into WordPress?

    It seems like every time WordPress gets close to a new release, I praise the WordPress team for integrating popular WordPress plugins into the WordPress software and I get several of the same responses…”If it already exists a WordPress plugin, why waste time installing it into the software?”

    Unfortunately, just because a WordPress plugin exists, it doesn’t mean that we aren’t better off having it built into WordPress.  Here are a few reasons:

    • Security Vulnerabilities – Improperly coded WordPress plugins can cause security vulnerabilities.   Now, this can obviously happen with the WordPress software, but it is more likely to be coded correctly or caught and fixed quickly when it is integrated into the WordPress software.
    • Wasting Database Resources – Poorly coded WordPress plugins can waste a lot of database resources.   Unneeded database queries can cause slow loading times, etc.
    • Everyone Has Access – Although we all know about WordPress plugins, I’m sure there are a number of users who don’t understand what they are, how they work, how to install them, etc.  Having it built into WordPress ensures that everyone has access to these features.

    It is with this thought process that I always try to use as few WordPress plugins as possible on my websites, and I rejoice every time popular WordPress plugins are built directly into WordPress.

    With WordPress 2.7 coming out soon, we’ll be getting a bunch of new plugins built into WordPress.  What plugins would you like to see built into WordPress next?  Keep in mind that the plugin would need to be something that would benefit most (if not all) WordPress users in order to be considered (not situational plugins).

    The five I would like to see built into WordPress next:

    1. All-in-One SEO Pack (or at least some parts of it) – This is very basic stuff and everyone who uses WordPress would benefit.
    2. Google XML Sitemaps – This is one of the most popular WordPress plugins and for good reason.  A sitemap.xml file should come standard with any blogging software.
    3. No Self Pings – Why does WordPress send pingbacks internally?  I think this one would be easy to integrate and people would love it.
    4. Popularity Contest – We have recent posts, recent comments, etc.  Who wouldn’t want this as an option on their WordPress theme?
    5. Database Manager – It would be nice if there was a way that you could easily backup and restore your database without the use of a WordPress plugin.

    Share your five most wanted in the comments!

  • Leave a Comment
  • How To: Displaying Your Most Commented Posts

    Though this isn’t quite the same as displaying your most popular posts in your sidebar, here is some code you can use to display the posts that have received the most comments.  You’ll want to place it in your sidebar where you want the code to be displayed.

    Most Commented Posts Code

    Go into your theme files and go to header.php file.   Somewhere within the </head> you’ll want to place the following code:

    <?php most_popular_posts($no_posts = 5, $before = '<li>', $after = '</li>', $show_pass_post = false, $duration='') {
    global $wpdb;
    $request = "SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS 'comment_count' FROM $wpdb->posts, $wpdb->comments";
    $request .= " WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish'";
    if(!$show_pass_post) $request .= " AND post_password =''";
    if($duration !="") { $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
    }
    $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
    $posts = $wpdb->get_results($request);
    $output = '';
    if ($posts) {
    foreach ($posts as $post) {
    $post_title = stripslashes($post->post_title);
    $comment_count = $post->comment_count;
    $permalink = get_permalink($post->ID);
    $output .= $before . '<a href="' . $permalink . '" title="' . $post_title.'">' . $post_title . '</a> (' . $comment_count.')' . $after;
    }
    } else {
    $output .= $before . "None found" . $after;
    }
    echo $output;
    } ?>

    If you’d prefer to display more than 5 posts, you can change the $no_posts = 5 code to whatever number you want to display.

    Okay, now, you need to figure out where you want to display these most commented posts (usually the sidebar) and place the following code:

    <?php most_popular_posts(); ?>

    And as is usually the case, if you want something easier, you can always go with a plugin such as the Popularity Contest plugin.

    To see other code that we’ve featured, check out our WordPress Code page.

  • Leave a Comment
  • Blogging Discussion: Registration Required to Comment?

    I’m not really sure if this is a trend or just coincidence, but over the past week I’ve noticed quite a few of the blogs that I stumble upon require you to setup an account before you can leave a comment.  Anyone know what is up with that?

    This is obviously a very useful WordPress feature for blogs that have a strong community built around their website, but I think most people should consider the consequences before they require you to register to comment.  A choice like this could keep truly hinder a new blogs growth or discourage a blogger who isn’t seeing the reader interaction they were hoping for.

    As with pretty much everything, there are some positives and some negatives to doing this.  Off the top of my head, here are a few positives and negatives of requiring registration to leave a comment on a blog:

    Positives of Registration

    • Spam Prevention – Requiring registration should stop spam completely.
    • More Options – Requiring registration opens up some interesting opportunities to customize comment appearance, allow you to create profiles, etc.   I’ve seen a few high profile websites do this, but the registration usually is optional instead of being required.

    Negatives of Registration

    • Less Comments – Some people value comments more than others, but I think most bloggers would find less comments to be a negative as the whole concept of blogging was formed around the concept of reader interaction with the writer.

    I personally do not leave comments on blogs that require registration because it just isn’t worth it to me.  I have enough accounts to manage without trying to remember my account information.   I also think things like spam can easily be avoided for WordPress users using tools like Akismet and Bad Behavior, Spam Karma 2, or Math Comment Spam Protection (which we use here).

    I’d like to hear what you think in the comments below.   How do you feel about blogs that require registration to comment?   Do you take the time to register or do you just decide not to comment at all?

  • Leave a Comment
  • How To: Adding the Post Authors Gravatar To Their Individual Posts

    One thing I am really excited about is that Gravatars are really starting to gain popularity now that Automattic has purchased and is supporting them.  And now that support is built right into WordPress, it opens up a lot of options for WordPress users.

    The most common place you’ll find a Gravatar is usually with an individual comment to help comments stand out.  Another place you will sometimes see them is in the sidebar, like we have it setup here at Hack WordPress.   One thing, however, that people are slowly coming around to is using Gravatars with blog posts to identify the author of the post.    This is something that is a great idea for a multi-author blog and something I’ve considered doing on this website.

    So, how would you go about setting up Gravatars to display with each individual post?   Over at ThemeShaper, Ian Stewart recently shared an easy way to do this.   You just need the following code:

    <?php echo get_avatar( get_the_author_email(), '64' ); ?>

    When used, WordPress will match up the e-mail address associated with the post author to determine what Gravatar to use.   The 64 is the size (pixels) of the Gravatar.

    Great find Ian!

  • Leave a Comment
  • How To: Display The Most Recent Comment First

    By default, a typical WordPress blog will display the very first comment at the top of the comments template. While I prefer this way, many others do not. If you are someone that would like your WordPress blog to display the most recent comment on top, Moses of WPThemesPlugin.com explains how to display recent comments on top.

    Unlike most of the WordPress hacks we’ve covered here at Hack WordPress, this one is not something that can be controlled from within the WordPress theme. You’ll have to actually go into the comment-template.php file (in the wp-includes folder) in order to make this adjustment. The good news is that it is REALLY easy. Click over to get step-by-step instructions on how to complete this hack. Great work Moses!

  • Leave a Comment
  • Support WordPress by Displaying Gravatars On Your Blog

    Do you have a Gravatar (Globally Recognized Avatar)? As a loyal fan of the WordPress software that runs each of my weblogs, I feel that it is important to support WordPress in any way that I can. Because this blog focuses on WordPress, that is especially true here.

    You may remember that last October Automattic, the company behind WordPress, purchased Gravatar. In the time since then, they have revamped the infrastructure of Gravatar to drastically speed things up, integrated it into the WordPress.com platform, and then updated the Gravatar WordPress plugin to function better with self-hosted WordPress blogs.

    If you don’t already have a Gravatar, I recommend you first sign up with Gravatar for a free account using whatever e-mail address you normally use to leave comments. Once confirmed, it will then prompt you to upload the avatar you want to use. You’ll need to use the e-mail address used for your Gravatar in the e-mail address field of the comment form (all in lower case) when leaving a comment for the Gravatar to display properly next to each comment.

    Now that Automattic is backing it, and WordPress.com blogs have integrated them, I think that over time Gravatar will continue to grow and the service will continue to get better. It is with that belief that I decided to add individual Gravatars to the comments on this blog (I also revamped the comments section to better support it). I would also like to see other self-hosted WordPress blogs begin to support Gravatars as well (many currently either support MyBlogLog avatars, or no avatars at all), so what I decided to do is update this post with an outbound link to your blog if your blog supports Gravatars.

    Here is what you need to do to get an inbound link to your homepage:

    1. Update your blog to display the commentators Gravatar with their comment. This can easily be done by installing one of the many Gravatar plugins (including the official Gravatar WordPress plugin) and then calling the plugin somewhere in your comments.php file. Depending on the theme, it will usually go in the commentblock section. If your blog already supports Gravatars, skip to step 2!
    2. Leave a comment below with a link to your blog.

    It is really that easy! I will then confirm your blog displays Gravatars with the comments and update this post with a link to your blog’s homepage, giving you a quality inbound link and hopefully some additional traffic. I’d like to turn this post into a showcase of WordPress.org blogs that support Gravatar! [Continue Reading…]

  • Leave a Comment
  • How To: Add a WordPress Comments Moderation Notifier

    Comments Off

    Depending on how you have your WordPress blog set up, you more than likely are receiving a flood of comment moderation notices in your e-mail inbox from incoming comments and trackbacks/pingbacks. This is not a bad thing, but can often become tedious as your comments continue to increase.

    The How-To Geek has created a solution to this problem by creating a WordPress Comments Moderation Notifier.  Once you’ve downloaded the software and installed it, it will place an icon in your Window’s system tray.  You will then want to add your site’s URL and login information in the settings, then determine how often you want it to check for moderation.  This also requires you to upload and activate a WordPress plugin.

    This application then uses the WordPress API to check for comments awaiting moderation and then will display a pop up box once there are comments that need moderating.  You can click on the icon to access your WordPress comments moderation queue.

    WordPress Comments Notifier Pop Up

    You can also easily access your WordPress moderation queue at your convenience by using the icon in your system tray.

    WordPress Comments Notifier

    If you decide to go through with this application, I recommend you place a shortcut to the notifier in your Windows startup folder so that it will be opened every time you restart your computer.

    One feature I would like to see is the ability to monitor multiple WordPress blogs for comment moderation.   A high percentage of WordPress users now seem to run more than one blog at a time, so this application won’t offer much value to those bloggers.  Otherwise, I find this application very impressive and useful for people running a single blog.

  • Leave a Comment
  • How To: Separating Your Author Comments in WordPress

    This post is being written as part of the Geeks Are Sexy How-To Contest

    Have you noticed while visiting some of your favorite blogs that many author comments are styled differently to help the authors comments to stand out?   This is something that isn’t overly difficult to implement on your WordPress blog, so I decided to write a quick how-to post explaining how you can easily adjust your WordPress theme to display different styles for each author.

    First, you’ll need to make some adjustments to the comments.php code.   Look for something similar to the following code:

    <li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">

    Replace the above code with the following code:

    <li class="<?php if ($comment->comment_author_email == "admin@yourdomain.com") echo 'author'; else echo $oddcomment; ?> item" id="comment-<?php comment_ID() ?>">

    You’ll want to modify admin@yourdomain.com to reflect the primary blog author’s e-mail address.  This will tell WordPress to check each comment to see if you are the author.   Now go to your CSS Stylesheet (style.css) and add the commands you would like to use for your author comments.   You’ll want to use .author to style your author comments.  I recommend pulling your standard comment code, then adjusting the colors to look different on your comments.  You can also add a logo through your stylesheet.

    How do I do this if my blog uses multiple authors?   If your blog features several different authors, you’ll want to make a slightly different adjustment to the above code so that it looks like this:

    <li class="<?php if ($comment->comment_author_email == "author@yourdomain.com") echo 'author'; else if ($comment->comment_author_email == "author2@yourdomain.com") echo 'author2'; else if ($comment->comment_author_email == "author3@yourdomain.com") echo 'author3'; else echo $oddcomment; ?> item" id="comment-<?php comment_ID() ?>">

    In the above example, we are assigning the primary author as .author and adding their e-mail address where it says author@yourdomain.com.   When the comment includes that e-mail, it will use the .author style from the stylesheet.  The second author will use .author2 for their stylesheet and replace author2@yourdomain.com with the 2nd author’s e-mail, etc.   Any comments that don’t include one of the above e-mails will use the standard styles.

    Once you’ve got your code adjusted and added the author(s) commands to your stylesheet you will be ready to start commenting!

  • Leave a Comment