WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. kanote
    Member
    Posted 2 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">
    <?php
    $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>';
    }?>
    </div>

    but this does nothing - there's nothing like depth_level i guess.
    Can someone help?

  2. kanote
    Member
    Posted 2 years ago #

    No ideas?

  3. alchymyth
    The Sweeper & Moderator
    Posted 2 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
    Member
    Posted 2 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.

    Cheers

  5. kanote
    Member
    Posted 2 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. shadim
    Member
    Posted 2 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
    Member
    Posted 2 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