farfromfearless
How To Quote Comments In A WordPress Comment List
Sometimes it's the little details that make WordPress themes really shine, other times it's the little features you can add that make working with a WordPress theme a nice experience for readers.
I received an email from a reader this afternoon, asking about one of the commenting features that I built into the Lemon Twist theme: quote comments.
Hi Chris,
I’m really curious on how you got that quote feature on your comment section. Do you mind sharing your code?
Cheers,
[author name omitted]
While this is not a new feature by and large, it is one that I thought would bring a sense of discussion to the linear WordPress comment format much like how forums work. I’ve attempted to use threaded commenting plugins, but they are ugly and overly complicated for something that should be fairly straight forward.
In any case, this is the JavaScript snippet that I wrote (you need jQuery, but comes with the theme)
// attach a function to the quote comment link
$('a.quote-comment').click( function() {
var tb = $('#comment');
var strQuote = $(this).attr('title');
// assign the value
tb.val('<blockquote>' + strQuote + '</blockquote>');
return false;
});
This is the result:
There are a couple caveats to this feature
- You can only quote one comment at a time, as I didn’t build in concatenation.
- It is not parameterized so you’ll have to customize it for your own theme.
- Requires some additional styling (no big deal).
If anyone wants to improve on this, feel free to share!
- Copyright 2008 farfromfearless. All Rights Reserved.
- Back To Top
- Home
Recent Comments-