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 ) {
<strong>$commentClass = bm_commentHighlight();</strong> ?>
<li class="<?php <strong>echo $commentClass;</strong> ?>">
<?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.
How was it for you? Let me know on BlueSky or Mastodon
Link to this page
Thanks for reading. I'd really appreciate it if you'd link to this page if you mention it in your newsletter or on your blog.