Is there a function to get comment's depth level (7 posts)

  1. kanote
    Posted 5 years ago #

    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?

  2. kanote
    Posted 4 years ago #

    No ideas?

  3. Michael
    Forum Moderator
    Posted 4 years ago #

    can you paste the full code of the file (whatever you are working on) into a http://pastebin.com/ 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?

  4. kanote
    Posted 4 years ago #

    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.


  5. kanote
    Posted 4 years ago #

    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 :P

  6. Shadi Manna
    Posted 4 years ago #

    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...

  7. kanote
    Posted 4 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic