Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$10
Customize Comment Reply Link
I want to modify the Comment Reply Link to use a lightbox effect for replies. I have the lightbox part working fine, as you can see on the demo site (http://themes.mikemcalister.com/wp/FreshStart/?p=346). Click "Reply to this Comment" to see the effect.
function my_replylink($c='',$post=null) {
global $comment;
// bypass
if (!comments_open() || $comment->comment_type == "trackback" || $comment->comment_type == "pingback") return $c;
// patch
$id = $comment->comment_ID;
$reply = 'Reply to this Comment';
$o = '<a class="comment-reply-link" rel="prettyPhoto" id="'.$id.'" href="'.get_permalink().'?replytocom='.$id.'#respond">'.$reply.'</a>';
return $o;
}
add_filter('comment_reply_link', 'my_replylink');
This code brings up the reply form in the lighbox as it should, but the reply doesn't work. It just adds the comment as a regular comment, not a threaded one.
$o = '<a class="comment-reply-link" rel="prettyPhoto" id="'.$id.'" href="#respond">'.$reply.'</a>';
Any help is appreciated, thanks folks!
This question has been answered.
Mike McAlister | 01/25/11 at 3:02pm
Edit
The experts have suggested, on average, a prize of $25 for this question.
(3) Possible Answers Submitted...
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-
Last edited:
01/31/11
4:27amOleg Butuzov says:Threaded comments works in a bit different way.
1) You should provide a way to show tham
2) A bit customize a replay form. -

Last edited:
01/31/11
4:27amJohn Cotton says:You have a hidden field element in the pop up form call "comment_parent"
which is set to 0. It should be the id of the comment clicked...
I guess that's because you're just taking the form html from the bottom of the page (I only had a quick look and I couldn't find quite how you were doing it).
So you need to add some code - a little bit of jQuery to react to the click (rather than relying on the rel="prettyPhoto" which I think you are now) and then set the form value from the id you've got stored in each link, and then show the lightbox...
JCPrevious versions of this answer: 01/25/11 at 3:36pm
-

Last edited:
01/25/11
3:37pmIvaylo Draganov says:There's a hidden input field in the comment form called "comment_parent". By default it has a value of "0":
<input type="hidden" value="0" id="comment_parent" name="comment_parent">
You have to change this value to the ID of the comment which is being replied to. Wordpress uses javascript to handle that (and also moving the comment form, but you obviously don't need that). You can try to extract what you need from wp-includes/js/comment-reply.js and apply it to your form.- 01/26/11 3:45am
Mike McAlister says:Would you be willing/able to make this change if I make this into a job instead and added more prize money?
- 01/26/11 2:07pm
Ivaylo Draganov says:I am not good with JavaScript. I think it should be something along the lines of:
// select comment reply link
J(".comment-reply-link")
// trigger event on mouse click
.click(function() {
// get id of the link(and also parent comment)
var parent = J(this).attr("id");
// set the value of input#comment_parent
J("#comment_parent").attr("value", parent);
})
// attach lightbox to it
.prettyPhoto({theme: 'light_square'})
I've not tested that. Try and see what you get. And you can remove the rel attribute from comment links and use their classes instead.
- 01/26/11 3:45am
This question has expired.
Current status of this question: Completed
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
