Support » Fixing WordPress » Is there a function to get comment's depth level

  • I can’t find function that could retrieve with informations like comment id .etc, also comment’s depth level. I know that there’s global variable $comment, but there seems it doesn’t allow to retrieve the depth level.
    I’ve tried:

    <div class="comm_reply">
    $comm_depth = $comment->depth_level;
    if ( $comm_depth < 4) {
    comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth'])));
    } else {
    echo '<style type="text/css">.comm_reply {visibility: hidden !important;}</style>';

    but this does nothing – there’s nothing like depth_level i guess.
    Can someone help?

Viewing 6 replies - 1 through 6 (of 6 total)
  • No ideas?

    can you paste the full code of the file (whatever you are working on) into a and post the link to it here, so one can see the code snippet in its context?

    there is a variable $depth (i am not sure if its global) which is used in wp_list_comments(), and this might also output a .depth-4 css class (depending on what code is used).

    what theme are you using?

    can you post a link to your site?

    instead of asking a very limited question, to which there is probably no direct answer, can you describe what you are trying to achieve?

    I use Scylla-Lite theme.
    Thanks for this hint about $dept var, now i’ll try find solution myself – when i end i’ll post it here.


    My temporary solution:
    added this code to style.css

    .depth-4 .comment-body .comm_reply {
        visibility: hidden;

    because i wanted to set such restriction: for every comment with depth level of 4, Reply button for this post must be hidden, because i want only 4 levels depth for comments under post. By now, it’s the easiest way 😛

    You can check whether the comment has a parent “$comment->comment_parent” to find whether you’re at the top level and potentially recreate the comment tree to know what level you’re at…

    Thanks, but how do i know, which variables i should use, to fetch $comment global variable? I’ve searched in Codex WordPress and found nothing about $comment variable. Does it mean, i have to browse through WordPress source code and find it myself?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Is there a function to get comment's depth level’ is closed to new replies.