WordPress.org

Ready to get started?Download WordPress

Forums

Threaded comments reply link disappears after 3 levels (3 posts)

  1. Osu
    Member
    Posted 3 years ago #

    Hi,

    I'm having trouble with threaded comments because the 'reply' link that normally appears under each comment disappears after I reach 3 levels down - I've set the 'Enable threaded (nested) comments' to 3 levels deep, but I'm assuming the reply link should always be there so people can continue commenting beyond three levels.

    My code for comments.php and the callback function for wp_list_comments() (called myfunction_comment) are below. Is there anything I'm doing wrong?

    myfunction_comment

    function myfunction_comment($comment, $args, $depth) {
       $GLOBALS['comment'] = $comment; ?>
       <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
         <div id="comment-<?php comment_ID(); ?>">
          <div class="comment-author vcard">
             <?php echo get_avatar('', 50); ?>
             <div class="comment-profile">
                 <span class="cauthor"><?php comment_author(); ?></span>
                <span class="cdate"><?php echo get_comment_date('d/m/y'); ?></span>
                 <span class="ctime">At: <?php echo get_comment_time(); ?></span>
             </div>
          </div> <!-- End div.vcard -->
          <?php if ($comment->comment_approved == '0') : ?>
             <em><?php _e('Your comment is awaiting moderation.') ?></em>
             <br />
          <?php endif; ?>
    
          <div class="comment-text"><?php comment_text() ?></div>
    
          <div class="reply">
             <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?> <div class="comment-meta commentmetadata"><?php edit_comment_link('Edit ', ' | ') ?><?php delete_comment_link(get_comment_ID()); ?></div>
          </div>
         </div>
    <?php
    }

    comments.php

    <?php
    /**
     * The template for displaying Comments.
     */
    ?>
    
                <div id="comments">
    <?php if ( post_password_required() ) : ?>
                    <p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'template_name' ); ?></p>
                </div><!-- #comments -->
    <?php
            /* Stop the rest of comments.php from being processed,
             * but don't kill the script entirely -- we still have
             * to fully load the template.
             */
            return;
        endif;
    ?>
    
    <?php
        // You can start editing here -- including this comment!
    ?>
    
    <?php if ( have_comments() ) : ?>
                <h2 id="comments-title">Comments</h2>
    
    <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
                <div class="navigation">
                    <div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">←</span> Older Comments', 'template_name' ) ); ?></div>
                    <div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">→</span>', 'template_name' ) ); ?></div>
                </div> <!-- .navigation -->
    <?php endif; // check for comment navigation ?>
    
                <ol class="commentlist">
                    <?php wp_list_comments('type=comment&callback=myfunction_comment'); ?>
                </ol>
    
    <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
                <div class="navigation">
                    <div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">←</span> Older Comments', 'template_name' ) ); ?></div>
                    <div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">→</span>', 'template_name' ) ); ?></div>
                </div><!-- .navigation -->
    <?php endif; // check for comment navigation ?>
    
    <?php else : // or, if we don't have comments:
    
        /* If there are no comments and comments are closed,
         * let's leave a little note, shall we?
         */
        if ( ! comments_open() ) :
    ?>
        <?php
        // Don't include 'Comments are closed' on pages.
        if(is_page()) : ?>
            <p class="nocomments"><?php _e( '', 'template_name' ); ?></p>
        <?php else: ?>
            <p class="nocomments"><?php _e( 'Comments are closed.', 'template_name' ); ?></p>
        <?php endif; ?>
    
    <?php endif; // end ! comments_open() ?>
    
    <?php endif; // end have_comments() ?>
    
    <?php
    // Ridiculously complex and stupid way to format the comments form
    $fields =  array(
        'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
                    '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" /></p>',
        'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
                    '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30" /></p>',
    );
    
    $defaults = array(
        'fields'               => apply_filters( 'comment_form_default_fields', $fields ),
        'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8"></textarea></p>',
        'must_log_in'          => '<p class="must-log-in">' .  sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
        'logged_in_as'         => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
        'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will <b>not</b> be published.' ) . ( $req ? $required_text : '' ) . '</p>',
        'comment_notes_after'  => '', // No tags allowed
        'id_form'              => 'commentform',
        'id_submit'            => 'submit',
        'title_reply'          => __( 'Leave a comment' ),
        'title_reply_to'       => __( 'Leave a comment for %s' ),
        'cancel_reply_link'    => __( 'Cancel reply' ),
        'label_submit'         => __( 'Post Comment' ),
    );
    
    comment_form($defaults); ?>
    
    </div><!-- #comments -->
  2. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    I haven't experimenterd....but after helping a few other people, I'm pretty sure the reply button disappears after the level is reached. If you want more reply buttons, I think you have to increase the threading depth

  3. Osu
    Member
    Posted 3 years ago #

    I think you're right - searching further I heard the same thing on another forum, which means you have a maximum of 2-10 replies per thread which for me is limited.

    Still, I suppose you have to put limits somewhere. Thanks for your reply!

Topic Closed

This topic has been closed to new replies.

About this Topic