Home/ Journal Bens Projects Binary Moon Archives About Ben Gillbanks Subscribe to Binary Moon Updates

Subscribe to Binary Moon Website Updates, it's Free and Easy to Stay in Touch

Search Binary Moon

Search Binary Moon

BM-Comment-Highlight Guide

In my excitement to get the BM-Comment-Highlight plugin out yesterday I forgot to tell you how to actually use the thing. Also since posting it yesterday I have though of another feature for the plugin so I have updated it accordingly.

How to use BM-Comment-Highlight

To use the plugin all you have to do is include a single php function call in your wordpress loop. This will return to you a string that you can use as a class in any way you see fit.

<?php foreach ( $comments as $comment ) {
	$commentClass = bm_commentHighlight(); ?>
	<li class="<?php echo $commentClass; ?>">
	<?php comment_text(); ?>
	</li>
<?php } ?>

When the function is called you will get a number of classes returned (most likely more than one). These let you style the comment appropriately.

The classes you get are:

  • author - the commenter is the post author
  • reader - the commenter is simply a reader of the blog
  • user - the commenter is a registered user
  • userID_# - the # is the user id of the registered user that has commented
  • pingback - the comment is a pingback
  • trackback - the comment is a trackback

Updates?

The update to the plugin is the additional feature of telling you if the comment is a comment, a trackback, or a pingback. This will let you style your incoming links in a more effective way.

24 Responses to “BM-Comment-Highlight Guide” Leave a reply ›

  • I downloaded it like a minute ago and am testing it in my new theme. I'll be back to let you know how it went. Although I should say you should give like a little preview of it at least on your plugin page. But it's just a thought.

  • ... is there a way to get it and avoid downloads?

  • Hi Ben-
    Loyal follower here -for Regulus
    Any chance of getting a more bold text on the left side categories?
    Any chance to have a larger font here-
    thanks so much-
    Jay

  • Profile

    Jenny - there's a screenshot up the top there. Is that not good enough?

    CodeOdd - it doesn't work on wordpress.com blogs I'm afraid

    Jay - that seem unrelated to the plugin? :) Regardless, these things are easy to change in the themes css files if you have access to edit them.

  • looool again Ben link is not working

  • this comment is because i forgot to check the notify me box

  • The link to download the plugin doesn't work...

  • Profile

    Aaarghh - they changed it back to how it was originally!

    I'll change them all again :S

  • im lost as to where to put this code and i think im pretty code snazzy

  • I'm an idiot. Will you please explain to me where you would place this? Please talk like you are speaking to a 5 year old, and then maybe I will get it.

    :O)

  • Hey. Great plugin, exactly what I have been looking for. I put the code into the comment.php file. So far so good - but how exactly do I define the classes?
    Cheers.

  • I love the idea, and have been looking for something similar for a while, but after putting the code in my template, my comments no longer load and I get an error: "Warning: Invalid argument supplied for foreach()".

    Any ideas?

  • Profile

    Georges - you stick the code in the comments template along with the comment loop.

    Matt - I got the sample code wrong. Take another look and let me know how you get on.

    Rob - the classes would be saved in the styles.css file. If you don't know css this will be harder.

  • Yup, that did the trick. Excellent! Thanks Ben!

  • Like Kevin, I consider myself pretty up-to-speed on WordPress and plugins and can't get my head around the installation of this at all.

  • Profile

    I'm afraid it's more than a case of uploading the plugin and activating it. I couldn't think of a nice clean way to include the comment styles so this is the best I have. If you could try to explain what you don't understand then I will see if I can be clearer. Obviously since I made the thing I understand what's going on so it all seems easy to me (it is, honest :) )

  • It kept giving me PHP errors, but I spent some time trying to fix it and got it myself.

    Never replied back but just got an email.

  • this is all you need to add to file:
    wp-content/themes/yourtheme/comment.php

    After:

    Add:

    Replace: "

    add to wp-content/themes/yourtheme/style.css
    .user { css styes here}
    .reader { css styes here}
    .author { css styes here}

  • Profile

    Kevin - php errors? I'm not aware of any. Glad you got there in the end :)

    Bill - your code isn't displaying :( If you email it to me through the contact form on my about page then I will add it to your comment.

  • Hey, I would really like to use this plugin but have no idea where and how to implement this code and what sort of things I could do with it, anyone what to give me some pointers?

  • Hi Ben,

    sorry to bother you but it can't get that plugin to work. I dl and activated it, put the classes in my .css file and the code in my comments.php.
    When i refreshe the page it stopps to load. I have erased the code in coments but let it in my .css file for further use.

    Problem is - i wrote part of my comments myself and now i'm stuck. Pls have a look:

     
    ">
    schrieb @ um

  • Hi,
    I'am trying using the plugins, but I'am really novice...

    Here is my comment.php file :
    [code]
    pour “”

    id="comment-">

    Says:
    comment_approved == '0') : ?>
    Votre commentaire est en attente de validation.

    " title=""> at

    [/code]
    I failed trying to modify my comment file... Can somebody modify it for me ? I always get parse of syntax error :(

  • What ist the wppressloop? Where must I put the code?

Leave a Reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

About me

About BenMy name is Ben Gillbanks. I'm a lover of Video Games, WordPress, Web Development and everything in between.

I have been working on the internet since 1998, and working with computers even longer. I am a hardcore Nintendo fanboy and have owned most of their consoles at one stage or another.

Read more about me on my about page.


Follow Me


Random Link-outs

  • Pro Theme Design Premium WordPress themes
  • Wpazo A blog that hits you over the head with the good links to all the best WordPress stuff
  • Darren Hoyt Awesome web designer
  • CodeAid Web development hints and tips
The Binary Network links to all my websites
bengillbanks.co.uk - Ben Gillbanks

Ben Gillbanks

All my websites under 1 roof, the easiest way to find out what I do

Pro Theme Design - premium WordPress themes

Pro Theme Design

Premium WordPress themes by web design pros (erm... that includes me)

Binary Joy - gaming news and reviews

Binary Joy

Gaming news and reviews

Binary Sun - play free online games

Binary Sun

Play and download free and paid games (many made by me)

Gaming Angel - download and play games online

Gaming Angel

Stacks of shareware games, free to try and cheap to buy