1

UPDATE: I'm going to update this one up at the top, because the solution I've found was with a differing filter hook. I'm going to look again at reply_link-specific hooks now that I better understand how to use them, but the solution to the main problem turned out to be easy once I found the right one: 'thread_comments_depth_max', which sets the default highest maximum depth to be set in Admin/Settings/Discussion.

Rather than explain it in detail, I'll link you to my github on the freshly minted plug-in.

https://github.com/CKMacLeod/WordPress-Nested-Comments-Unbound

For now, the rest of this question is overall obsolete, though kind of a record of alternative ways of achieving the same thing with greater difficulty and less general applicability.


Since 4.1, WordPress has made the filter "comment_reply_link_args" available, apparently (?) with the intention of letting us intercept and modify particular options normally set in the admin panel as they apply to comment reply links, while leaving everything else intact.

Though there are many aspects of the reply link that one might want to modify via alteration of the "args," the one that prompted this investigation on my part was max_depth, so I'll use it as my prime example.

When a nested comment thread reaches its maximum depth, the default functionality is for the comment reply link to disappear, but, on a comment thread with an active discussion at maximum_depth, continued conversation can be much easier to continue if the reply link continues to appear at the bottom of every comment - or alternatively, though a more complex implementation, at the bottom only of the thread - as if the comment thread at max-depth becomes a simple columnar/chronological thread.

The first alternative is easy to achieve via a hack of comments_template.php (linked below), deleting two lines:

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

However, since one of course does not want to hack WordPress core, the more common, preferred way to accomplish this end would be via theme or child-theme files and application of a callback comments function. Given how many different customized comment forms there are in different themes, this option might be preferable. However, if all you wanted to do was offer the "infinite replies" option for any theme or design using common WP functions, then the preferred method would be, if I am not mistaken, to filter the above $args where they hook up with comment reply link function(s).

In order to achieve the desired effect, or the simple version of it, a theme modification that works with an elaborate custom callback function is:

comment_reply_link( array_merge( $args,array(
‘depth’ => $depth,
‘max_depth’ => $args[‘max_depth’] + 1,
 ) ) );

I am copying everything except for the +1 modification as found to work applied to an actual theme's callback function. I am not completely sure about how all of the variables are declared, since, in my attempts to render the above as a filtering function used in a different theme, I continually ran into missing argument and argument not array errors.

Leaving off more complicated attempts to correct those errors, in a simple world the following would work:

function infinite_replies() {

$comment_reply_link_args = array(
   ‘max_depth’ => $args[‘max_depth’] + 1
   );

   return $comment_reply_link_args;
}

add_filter('comment_reply_link_args','infinite_replies', $comment, $post);

It does succeed in obliterating the reply link altogether - but nothing more. But at least it doesn't produce error messages... so I guess that's something.

I hope that the solution to this problem will point to ways to achieve other, more complex, potentially theme-independent comment thread modifications.

For reference, the basic documentation on comment_reply_link_args is here - http://wpseek.com/hook/comment_reply_link_args/ - and points directly to the relevant portion of comment-template.php.

0

Here's my solution. It relies on removing the original comment link and recreating it by appending it to the comment itself: https://www.webhostinghero.com/adding-infinite-replies-in-wordpress/

The only caveat is to make sure that wp_list_comments has been called with the default style argument. If it's not, then that element needs to be changed as explained in my article. Most of the time, the comments will be denoted by "div-content" so it won't be a problem.

  • I'm not going to mark this answer as a solution, since it doesn't directly address the narrow question. It does work somewhat broadly across themes, and presents a model for further work essentially bypassing the built-in reply link hooks (which may be necessary), and possibly pointing to better overall solutions than the max_depth + 1 approach, but at this level, and prior to a plug-in with replacement js file, it's not actually simpler than customizing child-theme files. – CK MacLeod Mar 11 '15 at 2:42
0

Thanks for raising this issue, it interests me as well. After searching everywhere for an acceptable solution, this is how I approach the problem on my site, at least for now:

comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => '25' )))

If you change '25' to, say, '1000', this will give you pretty much 'infinite replies', or am I missing something?

  • Re-reading my original post today, I see how it may have been hard for others to understand. Your solution also works, though is less "programmatic." There are others I've considered lately after adding IR to a blog with busy threads and noting commenter reaction. I still think the best way to implement the feature will require a better understanding of the underlying code. – CK MacLeod Apr 24 '15 at 21:18
  • Please update this topic if you come up with a better solution. Thanks. – pereyra Apr 25 '15 at 0:36
  • updated, both of you are welcome to offer contributions/comments at Github - am working now on various CSS solutions for different environments, both the common case in WordPress 2015, 2014, 2013, etc., and in commenting implementations where there's more flexibility. – CK MacLeod Aug 20 '15 at 2:09
0

See update and plug-in Git linked there. I'll link it again: The answer to the question is that comment_reply_link() may be the wrong hook. Full answer explained and implemented at https://github.com/CKMacLeod/WordPress-Nested-Comments-Unbound

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.