a The effect I want to achieve - at least at this point - is simply to have the comment reply link continue to appear below comments even after "max_depth" for threaded comments has been reached. Though eventually I might like to build more interesting possibilities into the new "infinite threaded comments" function, just having this much achieved would be a big advance for many busy blogs with threaded comments. (In fact, I think it would be a better default functionality than the current one, which is for threads to hit the wall, leaving it to users either to reply to a prior comment or start a new thread, both of which alternatives are clumsy and disadvantageous.)

It turns out that this is simple to achieve, as a blogger reported earlier this year (2014) at http://www.bhagwad.com/blog/2013/technology/allow-infinite-replies-with-wordpress-threaded-comments.html/ : Just delete or comment out the following lines in comment-template.php, under the get_comment_reply_link function:

if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) {

It works fine: Now, when we reach max-depth on the threaded comments, we can continue to reply in a non-threaded way "infinitely." However, deleting these lines means altering a WP core file.

I've tried a number of different solutions after searching through Stack Exchange and beyond. My most recent attempt, which I offer not because I have any reason to believe it's the closest I've come, but because at least it doesn't throw fatal errors (and because it includes most of the code of interest), is as follows:

function new_get_comment_reply_link( $args = array(), $comment = null, $post = null ) {

    $defaults = array(
        'add_below'  => 'comment',
        'respond_id' => 'respond',
        'reply_text' => __('Reply'),
        'login_text' => __('Log in to Reply'),
        'depth'      => 0,
        'before'     => '',
        'after'      => ''

    $args = wp_parse_args( $args, $defaults );
if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) {

    $add_below = $args['add_below'];
    $respond_id = $args['respond_id'];
    $reply_text = $args['reply_text'];

    $comment = get_comment( $comment );
    if ( empty( $post ) ) {
        $post = $comment->comment_post_ID;
    $post = get_post( $post );

    if ( ! comments_open( $post->ID ) ) {
        return false;

    if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) {
        $link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '">' . $args['login_text'] . '</a>';
    } else {
        $link = "<a class='comment-reply-link' href='" . esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";

     * Filter the comment reply link.
     * @since 2.7.0
     * @param string  $link    The HTML markup for the comment reply link.
     * @param array   $args    An array of arguments overriding the defaults.
     * @param object  $comment The object of the comment being replied.
     * @param WP_Post $post    The WP_Post object.
    return apply_filters( 'new_comment_reply_link', $args['before'] . $link . $args['after'], $args, $comment, $post );
function new_comment_reply_link($args = array(), $comment = null, $post = null) {
    echo new_get_comment_reply_link($args, $comment, $post);

To save you a trip to comment-template.php at http://phpxref.ftwr.co.uk/wordpress/nav.html?wp-includes/comment-template.php.source.html , I've taken the code that appears there from lines 1332 - 1446 at this linked version of the core file, a portion that I believe has not changed in several years, and have tried to hook in two new functions that repeat everything, but this time with the "return" removed, and the final bracket moved down. In other words, "If the conditions arise that normally cancel the reply link, let the reply link appear anyway." Note: I've also tried putting the add_filters first, as is I think more often done.

Doesn't work. I've also tried removing the if statement and return entirely, removing the old functions, changing the variables, etc. It looks like it should be the simplest thing in the world, but I'm stumped, and wondering if I should be trying some completely different strategy.

  • The code part you are quoting seems to be acting entirely on inputs passed. Why not just passed different inputs to achieve the behavior? – Rarst Dec 27 '14 at 18:01
  • The main input in question - thread depth - is set in Admin. We need to remove or override it just for the get_comment_reply_link function (or set of two functions), as accomplished by deleting the lines from the core get_comment_reply_link function (which we don't want to have to do). So, in short, we're looking for the "correct" way to remove the lines or achieve the same effect. – CK MacLeod Dec 29 '14 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.