Title: Control nested/child comments
Last modified: August 19, 2016

---

# Control nested/child comments

 *  Resolved [Mark](https://wordpress.org/support/users/markjcasey/)
 * (@markjcasey)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/control-nestedchild-comments/)
 * Hi guys
 * This doesn’t refer to the styling of child comments, that’s pretty easy to change.
 * I’m interested in adding or removing elements in a child comment. At the moment
   it just pulls everything from a normal comment.
 * Is there a way to tell if a comment is a child so I can change things?
 * I’ve been playing around with $comment_depth but not had much luck.
 * Any ideas?
 * Thanks : )

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Joseph](https://wordpress.org/support/users/jpe24524/)
 * (@jpe24524)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/control-nestedchild-comments/#post-1765517)
 * You’ll need to create a [custom callback function](http://codex.wordpress.org/Template_Tags/wp_list_comments#Comments_Only_With_A_Custom_Comment_Display)
   with condition such as
 *     ```
       if ($depth > 1) {
       	/* It's a nested comment */
       }
       ```
   
 *  Thread Starter [Mark](https://wordpress.org/support/users/markjcasey/)
 * (@markjcasey)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/control-nestedchild-comments/#post-1765547)
 * Thanks again for the reply Joseph… and thank you coco001 for the spam.
 * I’m actually already using a custom comment display using the callback function.
 * Where do I slot this condition into the function? I assume it would be here somewhere…
 *     ```
       if (!function_exists("custom_comment")) {
       	function custom_comment($comment, $args, $depth) {
       	   $GLOBALS['comment'] = $comment;
       ```
   
 *  [Joseph](https://wordpress.org/support/users/jpe24524/)
 * (@jpe24524)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/control-nestedchild-comments/#post-1765548)
 * Yes, it should be placed somewhere in that function. I can’t tell you exactly
   where and what to add because I don’t know what’s in it and what you’re trying
   to do.
 * The conditions are `$depth == 1` and `$depth > 1` for parent and child comments
   respectively.
 *  Thread Starter [Mark](https://wordpress.org/support/users/markjcasey/)
 * (@markjcasey)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/control-nestedchild-comments/#post-1765552)
 * I’m trying to add some extra text on nested comments, that doesn’t appear on 
   the parent ones.
 * I’ve tried adding this just before the comment reply button from within my custom
   comment display.
 *     ```
       <?php if custom_comment($depth > 1) { ?>
       <p>Some text here</p>
       <?php } ?>
       ```
   
 * That breaks my page though : (
 *  [Joseph](https://wordpress.org/support/users/jpe24524/)
 * (@jpe24524)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/control-nestedchild-comments/#post-1765553)
 * Try this:
 *     ```
       <?php if ($depth > 1) { ?>
       <p>Some text here</p>
       <?php } ?>
       ```
   
 *  Thread Starter [Mark](https://wordpress.org/support/users/markjcasey/)
 * (@markjcasey)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/control-nestedchild-comments/#post-1765554)
 * Ah, right. I didn’t need to mention the function again.
 * Sorted, works a charm. Thanks again.
 *  [Joseph](https://wordpress.org/support/users/jpe24524/)
 * (@jpe24524)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/control-nestedchild-comments/#post-1765558)
 * You’re welcome. 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Control nested/child comments’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [Joseph](https://wordpress.org/support/users/jpe24524/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/control-nestedchild-comments/#post-1765558)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
