[wp-trac] [WordPress Trac] #41821: REST API: Add support for threaded comments

WordPress Trac noreply at wordpress.org
Thu Jul 12 05:09:32 UTC 2018


#41821: REST API: Add support for threaded comments
-------------------------+-----------------------------
 Reporter:  rmccue       |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Future Release
Component:  REST API     |     Version:  4.7
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  rest-api
-------------------------+-----------------------------
Changes (by brgweb):

 * keywords:  needs-patch => has-patch
 * focuses:   => rest-api


Comment:

 @birgire I've added a diff to this ticket that enables threaded comments
 in rest api.

 It adds a boolean query parameter "hierarchical". Instead of passing
 "hierarchical" straight to WP_Comment_Query, it retrieves only top level
 comments (or just the first level if "parent" is set) and retrieve
 children inside prepare_items_for_response method.

 I've tested with fake data and in a production environment and it worked
 as expected.

 Replying to [ticket:41821 rmccue]:
 > (I don't think we have a tracking ticket for this already.)
 >
 > We should add support for threading comments, particularly in "flat"
 mode. Flat mode would allow threading in frontend code relatively easily.
 >
 > The only issue with this is that it will overflow `per_page`. We
 intentionally treat this as an indicator and occasionally have less items
 already (if they're filtered inside the `get_items()` loop, e.g.), so I
 don't think this is a huge issue. In addition, threaded mode should be
 opt-in in any case.
 >
 > Previously: https://github.com/WP-API/WP-API/issues/1612

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/41821#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list