In-Reply-To and Infinite Replies

Over at OT, I have added a variation on automatic “In Reply To” commenting links, which I believe may once have been more common, and which some users find helpful in sorting out long discussions, especially in nested comment threads at “max depth,” and even more when an “Infinite Replies” capacity has been enabled.

Infinite Replies (IR)

I summarized “Infinite Replies” in my introductory post on them at OT as follows:

When comment thread “nesting” reaches maximum “depth” reply links will continue to appear underneath new comments, and the actual replies will appear at the bottom of the given sub-thread.1 This solution as implemented will not be the ideal implementation – which would involve more complex dynamics and formatting – but will be a good start, at least relieving us on busy threads from having to scroll all the way to the top in order to reply to a comment far below.

Over the course of months in 2014-5, I kicked around various ways of achieving this effect with WordPress developer Bhagwad Jal Park, who had authored a simple hack for it, and also is the one who named the result “Infinite Replies”2, as described in his post in late 2013: “Allow Infinite Replies with WordPress Threaded Comments.”

Executing Bhagwad’s hack required committing a WordPress developer’s sin, hacking a WordPress core file, whose main practical drawback is the requirement that a site manager re-do the hack every time WordPress does a major update or update affecting the core file in question. The recommended – and better – practice is to add or modify whatever function or process in question via theme or plug-in, and there are almost always a range of choices available.

Bhagwad finally achieved his own non- or less-hacky solution via a method he described in detail in a later post, “Adding Infinite Replies in WordPress.” The solution that he details there requires 1) creating a substitute “Comment-Reply-Link” function and 2) adjusting it if necessary so that it works with the Javascript that locates comment reply boxes on a comment thread.

You can examine Bhagwad’s solution at the linked post. The solution I applied at OT was much simpler, since all it required was making an edit to a WordPress child theme, a non-sinful method for making such modifications. Doing so bypasses the lost-to-upgrade problem, which can affect themes in the same way it affects WP core files. Another alternative would be to develop a theme-independent plug-in, and the best solution would likely involve developing a full-fledged independent commenting system (comment “Walker” function or even more elaborate), but those are projects for a different day/month/season/year.3

At OT, all I had to do was locate the “comment_reply_link()” function, which on the Expound theme used at OT happens to be located in a special template-tags.php file. The key portion looked like this:

Adding infinite replies turned out to consist of adding a space and two little characters to the max_depth line (a recursive solution of the sort beloved by programmers, which originated, in passing, in a StackExchange “answer” on a different question):

Depending on how a given theme is constructed and written, this solution may have to be amended in different ways. In order, for instance, to apply it at this blog, whose theme does not deploy significant customizations of built-in WP commenting, I would need to write a new filter function or possibly a comment “Walker” function, a project for another day.4

Though Bhagwan wanted to avoid writing his own Walker, the eventual best solution will involve doing so, I expect. If done in a standards-compliant way, it would not interfere with typical theme commenting customizations accomplished on the level of styling/formatting, or by use of plug-ins, or by minimal additions to normal WP commenting functionality.

In Reply To Links (IR2L)

After adding Infinite Replies to OT, several users noticed what they experienced as a time-displacement confusion, since, in a give mono-columnar sub-thread of the sort that results at maximum depth, it is possible for particular comments to appear above other comments made earlier. In other words, contrary to my initial description, new comments do not always appear at the bottom of the new thread. Actually, what we’re seeing in such a long thread will be comments that in one sense are at different depths, but for display purposes are at the same depth.

For independent but overlapping reasons, some commenters also like being able to tell immediately what a given commenter is specifically replying to, and, especially in a long, complicated discussion, may also like to be able to find an original comment. Luckily enough for both purposes – if not necessarily a complete solution, especially with reference to an ideal “IR” display and functionality – the code snippet for “in reply to” links has been floating around in the WordPress ocean of snippets for years.

The example I happened to run across is written a little differently than in my normal PHP style, but it works, so why complain? Usually, the link is written out “in reply to,” but I wanted something more compact for OT. I also wrapped the addition in its own div + CSS class so I could style it:

It was easier to add directly to the Expound Child template-tag.php file than it would or will be to add on this blog – probably by adding a filter function or in the context, as above, of writing a new comment Walker. Just to complete these notes for now, I styled the “comment-irt” div as follows:

…producing this:


You can view or try it on any thread at OT. (The above image happens to come from the “Why Nine Innings” comment thread.)


  1. Not precisely true: see discussion under IR2L. []
  2. Obviously the replies aren’t infinite, but rather more open-ended or pervasive or something, but it’s kind of fun to think of them as infinite and of replies at max depth as entering the Infinite Zone. []
  3. Also, just in case it doesn’t go without saying, neither Bhagwad’s nor my solution will likely be useful to someone using a third-party commenting system like Disqus or Livefyre. []
  4. The WP Codex outlines the process in relation to comments in its page on the wp_list_comments() function. Starting with the page on the so-called “Walker Class” may induce blackouts in beginners… []

Home Page  Public Email  Twitter  Facebook  YouTube  Github   

Writing since ancient times, blogging, e-commercing, and site installing-designing-maintaining since 2001; WordPress theme and plugin configuring and developing since 2004 or so; a lifelong freelancer, not associated nor to be associated with any company, publication, party, university, church, or other institution.

4 comments on “In-Reply-To and Infinite Replies

Commenting at CK MacLeod's

We are determined to encourage thoughtful discussion, so please be respectful to others. We also provide a set of Commenting Options - comment/commenter highlighting and ignoring, and commenter archives that you can access by clicking the commenter options button (). Go to our Commenting Guidelines page for more details, including how to report offensive and spam commenting.

  1. Hey, glad you managed to get this to work for your theme!

    I used the same “hack” to add a “parent comment” link – by just pre-pending it to the comment text as I wrote here:

    I’m also thinking that maybe the comment styles of Google+ and Facebook are pretty elegant. They have a effective “comment depth” of just 2 and seem to not have real problems with long discussions.

    Haven’t yet worked up the courage to implement that though!

    • Hey, Bhagwad.

      The code I used in the above is kind of “IRT Classic” – if you search for its constituent parts you’ll find them used in a lot of places. It may appear in the WordPress Codex somewhere, and I wonder if comment_parent wasn’t added to WP core for precisely this purpose.

      I like your version of IRT via function. In fact, I think I will very soon try a version of it to add IRT links to this blog. Once that’s accomplished, it ought to make for a cute little plug-in, assuming there isn’t one already in the repo I never noticed. (If you or someone else beats me to the punch, I’ll try it out here.)

      I’m not sure about Google+ and Facebook for long discussions – either at the sites themselves or in comment threads styled to emulate them – in part because I’ve never been in or attempted to follow one in such a situation, though I have been in long, un-threaded discussions that eventually became very burdensome to try to develop, since by comment 100 or 200 there may be several discussions going on at once, or threads that have been abandoned because they’ve just become to difficult to find and follow.

      Because the Ordinary Times site has a unique commenter community, featuring a number of intelligent, voluble, and polite yet argumentative souls, many of whom have been discussing political and cultural topics with each other for years now, the comments and sidebar and sidebar-to-the-sidebar discussions sometimes get long and involved, putting more or a premium on whatever enhancements you can think of: My first goal since I started working at OT was doing things that would make my own participation easier.

    • Thanks, Marc – I’ll take a look at it, though I’m a little confused by the description, specifically by what you mean by “2nd level thread,” since it sounds like you’re saying “not every comment on threads at depth 3, 4, etc.”

      Anyway, adding the reply links is good, and it’s cool if you’ve come up with a way to do it that doesn’t require editing or replacing template files, but I was as interested in, and eventually got to, extending threads “infinitely” (or unboundedly), so that really long ones don’t jam up confusingly wherever they end – was more of a concern at a busy blog where threaded conversations semi-regularly go into the hundreds of comments.

1 Pings/Trackbacks for "In-Reply-To and Infinite Replies"
  1. […] snippets and explanations on IRTL and also on Infinite Replies available at my personal blog. […]

Commenter Ignore Button by CK's Plug-Ins

Leave a Reply

Your email address will not be published. Required fields are marked *



Noted & Quoted

[E]ven Fox didn’t tout Bartiromo’s big scoops on Trump’s legislative agenda, because 10 months into the Trump presidency, nobody is so foolish as to believe that him saying, “We’re doing a big infrastructure bill,” means that the Trump administration is, in fact, doing a big infrastructure bill. The president just mouths off at turns ignorantly and dishonestly, and nobody pays much attention to it unless he says something unusually inflammatory.On some level, it’s a little bit funny. On another level, Puerto Rico is still languishing in the dark without power (and in many cases without safe drinking water) with no end in sight. Trump is less popular at this point in his administration than any previous president despite a generally benign economic climate, and shows no sign of changing course. Perhaps it will all work out for the best, and someday we’ll look back and chuckle about the time when we had a president who didn’t know anything about anything that was happening and could never be counted on to make coherent, factual statements on any subject. But traditionally, we haven’t elected presidents like that — for what have always seemed like pretty good reasons — and the risks of compounding disaster are still very much out there.

Comment →

So, does Mitchell make any money on the work, which has been shared so many times? He uploaded a high-res image of the symbol and granted permission for anyone to use it personally for free. But for those who want to support his work or simply want something readymade, you can also buy T-shirts, sweatshirts, mugs, and journals emblazoned with the symbol through Threadless.“I really just want to spread the image as much as possible and cement it in history,” Mitchell says. “In all honesty, the amount I’ve made from my Threadless shop so far is still less than my hourly rate, so I don’t really see it as a big deal. If you look at my Twitter, half the replies are people wanting to know where they can buy a shirt. Threadless is happy to help them out with that, and so I’m happy to let that happen.”Now that the symbol has flooded our streets and our timelines, Mitchell just has one request: “Impeach this idiot already,” he says.

Comment →

This is a Waterloo moment for Trump, the tea party and their alliance. They have been stopped in their tracks not only by Democratic opposition but because of a mutiny within their own ranks. Although never particularly liked or respected, it is now clear that they are no longer feared. The bankruptcy of their ideas and their incompetence have been exposed. Their momentum has been dissipated. Their rejection of political norms has itself been scorned. Our long national nightmare may finally be coming to an end.

Comment →
CK's WP Plugins


Extraordinary Comments

CK's WP Plugins