Hello,
I’m trying to create custom commenting on a buddypress install. I basically would like to have 2 levels of nested comments, and infinite replies without the indentation causing comments to be unreadable. I found this code, but I think it’s specific to WordPress comments, not buddypress:
Home » WordPress » How to Have Infinite Replies with WordPress Threaded Comments
How to Have Infinite Replies with WordPress Threaded Comments
WordPress doesn’t allow to have infinite replies beyond the maximum nested comment depth. In this tutorial, I’ll show you how to create a “Reply” link for all threaded comments, regardless of the depth.
Table of Contents
Code for Infinite WordPress Replies
No Need to Modify Core WordPress Files
Why Increasing the Max Depth via Code Doesn’t Work
Allow Flat Inline Replies Like on Facebook
Related to WordPress Comments:
How to Disable Links in WordPress Comments
How to Remove “Comments are Closed” from WordPress
How to Block WordPress Comment Spam Using Cloudflare
How to Display Error Messages in the WordPress Admin
In this screenshot, I’ve set the nested comments level to three:
WordPress Nested Comments Three Levels Deep
WordPress Nested Comments Three Levels Deep
WordPress will nest comment replies to this depth and then stop showing the “Reply” link at the bottom of every comment, as shown here:
WordPress Comment Reply Missing on Maximum Depth
WordPress Comment Reply Missing on Maximum Depth
Because of this limitation, visitors can’t have an ongoing conversation on your site, thereby stifling debate. The code below fixes this problem.
Code for Infinite WordPress Replies
To solve the above problem, paste the following code into your theme’s functions.php file, or better yet, use a custom plugin for code insertion. Whichever way you choose, here’s the code you need:
// Add a custom reply link for infinite comments
function add_a_reply_link($comment) {
$temp = get_comment_id();
$comment_handle = get_comment($temp);
// $comment_handle = get_comment(get_comment_id());
$comment_link = get_comment_link($comment_handle);
$comment_id = get_comment_id();
$post_id = get_the_id();
$author = get_comment_author();
$comment= $comment . ‘<p>Reply</p>’;
return $comment;
}
add_filter(‘get_comment_text’, ‘add_a_reply_link’);
// Remove the default reply link
function remove_reply_link() {
return ”;
}
add_filter(‘comment_reply_link’, ‘remove_reply_link’)