Wordpress Howto - Add unique author comment styles to any theme

I love using Wordpress. One of my favorite time-wasters has become flipping through newly-submitted Wordpress themes at places like Weblog Tools Collection (here’s a sample theme post) looking for that perfect theme for my blog. Unfortunately, when I made a list of style elements I liked, not one theme has all the elements I want. So, I started going through my list and decided to add my favorite style elements to any theme. First up - styled author comments.

Styling author comments with a unique look is a great way to allow readers to immediately tell the difference between readers’ comments and an author’s responses. Some popular blogs that style authors’ comments include:

TechCrunch: see the article on Mig33 for a recent example.
techcrunch

ReadWriteWeb: see their ’social graph’ article for a recent example.
readwriteweb

Alex King’s blog: see his article on Google’s sharing service for a recent example.
alexking

I like the extra panache Alex King’s comments have with the gradient, so that’s what I’ll use.

First, while I’ll be showing how to edit your theme’s files to add custom author comment styles, you could do the same with a plugin like Jan Olsen’s Comment Highlighter plugin (which appears to have moved to Google Code). I personally have struggled with plugin compatibility problems (most of which, it seems, unfortunately stem from Google Sitemaps, one of my favorite plugins). To reduce the chance of conflicting plugins taking down the entire site, I started paring them down to just the necessities - in particular, I stopped using any plugin I could easily re-create with some code in the theme files. In my opinion, the five minutes it takes to copy my code between themes when changing is worth saving potentially hours’ worth of troubleshooting time. If you’d rather use a plugin, or don’t have access to edit your theme files, I’m sure Olsen’s plugin is a good one. Otherwise, make time for five minutes’ worth of easy editing and read on.

To begin, we’ll be editing two theme files: style.css and comments.php, which you’ll find in your /wp-content/themes/[theme name]/ directory. First, in comments.php, find the lines that read:

<?php foreach ($comments as $comment) : ?>
<li class=”<?php echo $oddcomment; ?>” id=”comment-<?php comment_ID() ?>”>

Modify the second line to add a unique style if both the comment author name and email address match a particular blog author’s information (make sure it matches what is listed in the user’s profile):

<li class=”<?php if ($comment->comment_author == ‘AUTHOR NAME GOES HERE‘ && $comment->comment_author_email == ‘AUTHOR EMAIL ADDRESS GOES HERE‘) echo ‘authcommenthighlight’; elseif ($comment->comment_author == ‘ANOTHER AUTHOR NAME GOES HERE‘ && $comment->comment_author_email == ‘ANOTHER AUTHOR EMAIL ADDRESS GOES HERE‘) echo ‘authcommenthighlight2′; else echo $oddcomment; ?>” id=”comment-<?php comment_ID() ?>”>

Now we need to add the styles “authcommenthighlight” and “authcommenthighlight2″ (or whatever you name them) to our theme. Since I’m currently the only author on this blog, I’ll just be adding “authcommenthighlight.” First, create your gradient image. I had the best luck making mine 12×48 pixels, and selected two colors from my theme. I used Photoshop to make the gradient, but you can use just about any photo editing software - for that matter, even Microsoft Word can create gradients. If you’re not sure how to create a gradient, here’s some sample tutorials: Photoshop, Paint Shop Pro, Paint.net and GIMP. Here’s what I ended up with, using the top header (#237AB2) and sidebar (#EEEEEE) colors:

Gradient example

Now, add the “authcommenthighlight” style to your style.css, setting the gradient image to repeat along the top of the comment and the background to match the bottom color of the gradient:

.authcommenthighlight {
background:#EEEEEE url(/images/grad.jpg) repeat-x;
}

To kick it up a notch, try modifying padding, margin, borders, font colors and other style elements. Get an overview of additional CSS elements you can modify at DevGuru and W3Schools.

Now you and your authors will each have your own unique comment style that separates your comments from visitors’ comments. Of course, there’s a downside to styling comments by matching author names and email addresses - if someone knows your username and email address, they can leave a comment that receives the unique style. I haven’t dug into the Wordpress hooks enough to know whether there’s a way to code around this problem - anyone know?

Anyone have different methods of adding unique styles to author comments? I’d love to hear them in the comments below.

Thank you for visiting NoShrinkwrap. If you enjoyed this article, check out the related posts below and subscribe to our feed.

Deal or No Deal - is “Big Money” in the Web 2.0 briefcase?

Today is a busy day in the Web 2.0 space with lots of money flowing and rumors substantiated-

  • Everyone is reporting the CBS purchase of Last.fm for $280 million (which follows the recent purchase of Wallstrip for $5 million). As an aside, this could be an interesting purchase, particularly with the recent spat between Viacom (also owned by CBS parent National Amusements) and Google’s YouTube - is that a precursor to where CBS intends to leverage Last.fm? Could we soon see a property emerge that streams CBS and Viacom shows, makes recommendations based on your profile and makes the shows available for purchase?
  • TechCrunch and GigaOM both claim eBay will confirm the rumored Stumbleupon purchase later today. Despite the blogosphere’s confusion on how Stumbleupon fits eBay’s business, I think it’s a smart move and complements eBay perfectly. Here’s a snippet of what I said last time the rumor broke:

    StumbleUpon’s new feature StumbleThru could very well be the feature that pushes eBay to new community-centered heights. Improved searches, randomly discovering auctions based on user preferences, a comment and product rating system, tagging - eBay appears to be purchasing in one fell swoop an entire community of people already enjoying and familiar with the process of rating and commenting on sites who would likely gladly do the same for eBay auctions… eBay could even further expose auctions by offering a “stumble this on eBay” option in browsers and an official eBay widget or “blog this” feature. Amazon has shown us that adding community features is a great way to increase visibility and user-retention; with StumbleUpon, eBay could leapfrog into the community game and improve its existing technology at the same time. It’s a win-win.

    Read the original entry for more.
  • TechCrunch is also reporting the Fox Interactive purchase of both Photobucket and Flektor. I have to admit - this one stumps me a bit. Perhaps the next American Idol will be American Director, featuring a slew of user-contributed video submitted through MySpace. Or perhaps MySpace will move into the video and advertising markets, as it started in the indy music space. They must have some interesting plans up their sleeves.

With all these reports of money flowing through Web 2.0, I barely noticed an article that talks about where the real money is: domaining.

Meet Kevin Ham. Ham owns a portfolio of over 300,000 domain names that, together with other assets, purportedly generates over $70 million a year in revenue. His domains generate money by serving targeted ads to visitors using a practice called “direct navigation” or “direct search” - those of us who, instead of searching Google for wedding shoes, type “weddingshoes” into the browser address bar. The browser automatically attaches .com by default, landing you at weddingshoes.com - which, of course, Ham owns. Ham serves advertisements that look like real links, people click on the ads, and Ham makes money. Multiply that by 300,000 and you’ve got an impressive business model.

With that in mind, I read an interesting article at The Alarm Clock this morning about NameMedia, a company that both maintains a portfolio of domains (which are available for purchase through an in-house marketplace) and provides targeted advertising for domainers. The New York Times reports that

Youssef Squali, an analyst with the investment firm Jefferies & Company, said NameMedia faces stiff competition, “but I see these guys as the front-runner.” Among other things, Mr. Squali said the profit margin at NameMedia was 40 percent — a number that other industry executives said fairly represents the category over all.

“They’re paying nothing to acquire a customer,” he said. “I think the next wave of I.P.O.’s will be around this area.”

The direct navigation market attracted more than $800 million in ads last year, which publishers largely shared with Google and Yahoo. That figure could reach $1.1 billion in 2007, said Jordan Rohan, an analyst with RBC Capital Markets.

40% of $1.1 billion in profit - that’s a lot of money. And Frank Schilling (a big-time domainer himself) says that’s a conservative number - NameMedia could be making as much as 70-80% profit. And it stands to get even better - by leveraging RSS feed aggregation, vidcast content and other consumable information, domainers could turn their cesspools of advertising into information portals, bringing repeat traffic. Repeat traffic! Can you imagine someone choosing to visit an advertising site?

With information becoming more consumable through automatic feeds, advertising being served through more interesting channels, and an impressive profit margin, it’s no wonder NameMedia is being identified as the next big IPO. Throw in some relevant and authoritative-sounding articles served through RSS, scraped user reviews and ratings and a bunch of ads, and you’ve got a money-generating portal people benefit from visiting - Billboards 2.0.