Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm currently working with custom comment meta, and I have some custom additional field such as rating etc, when user write a comment ( not comment reply ) I want to show the rating field, but when it's on reply comment state I want to remove this field.

Is there a build in conditional function to check whether it's in a reply state or not? or any other way to achieve what I want?

share|improve this question
add comment

1 Answer

Check for the comment_parent:

if( '0' != $comment->comment_parent ){
    // this is a reply
}
share|improve this answer
    
thanks for the answer @diggy, I'm using comment_form() function to output the comment in the theme, so how can I do this using comment hook? –  nackle Jan 16 '13 at 0:21
    
comment_form displays the form, I assume you want to customize comments, and not the form? Check for wp_list_comments to find out what callback function is used to display comments, e.g. in twentytwelve the callback is twentytwelve_comment, which is located in functions.php. Edit the callback function to incorporate the rating data, e.g. <?php if ( '0' == $comment->comment_parent ) : ?>RATING STUFF GOES HERE<?php endif; ?> –  diggy Jan 16 '13 at 0:30
    
I just made it work using global $comment in the comment_form_after_fields action, one thing not going well is when I open the link to reply manually it work eq.(localhost/wp/?p=123&replytocom=17#respond) , but not while using comment-reply.js when the comment is just move to another place but not removing the field. Any idea? –  nackle Jan 16 '13 at 0:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.