WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 8 months ago

#41740 new enhancement

Add comment count to "replies" link in post responses

Reported by: rmccue Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: REST API Keywords:
Focuses: Cc:
PR Number:

Description

Right now, you can preload comments using embedding with the linked "replies" resource. This is great, but there's no way to know whether you should try loading more. Fetching the resource directly would give you the total in the X-WP-Total header, but you lose this when embedding.

While this is generically a problem with the loss of headers from embedded resources, I don't think we really need a generic solution. Even when not embedding, a comment count is useful for archive display of a list of posts.

We should add the comment count (using wp_count_comments) to the "replies" link:

{
    "replies": [
        {
            "href": ".../wp/v2/comments?post=42",
            "embeddable": true,
            "count": 12,
        }
    ]
}

Attachments (1)

41740.diff (489 bytes) - added by wongalex 8 months ago.

Download all attachments as: .zip

Change History (2)

#1 @wongalex
8 months ago

I can look at this as my first bug :)

EDIT: Actually I looked through and it's just a one line change with the change being above haha. Ignore this.

Last edited 8 months ago by wongalex (previous) (diff)

@wongalex
8 months ago

Note: See TracTickets for help on using tickets.