[wp-trac] [WordPress Trac] #62390: REST API: add WP_REST_Posts_Controller route to fetch page counts (was: REST API: proposal for new endpoint to fetch post counts by post status)

WordPress Trac noreply at wordpress.org
Mon Dec 9 06:50:24 UTC 2024


#62390: REST API: add WP_REST_Posts_Controller route to fetch page counts
--------------------------------------+------------------------------
 Reporter:  ramonopoly                |       Owner:  (none)
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  REST API                  |     Version:  trunk
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------------
Changes (by ramonopoly):

 * version:  6.7 => trunk


Old description:

> This ticket tracks proposal in Gutenberg to develop a new Core endpoint
> to fetch the total number of post counts by post status using
> [https://developer.wordpress.org/reference/functions/wp_count_posts/
> wp_count_posts].
>
> https://github.com/WordPress/gutenberg/pull/66294
>
> There is a need for a performant post counts check in the block editor.
> See:
> https://github.com/WordPress/gutenberg/pull/65223#issuecomment-2381323815
>
> Contrast this feature with `$query->found_posts` which returns the total
> count for a specific query only and would degrade performance given `n`
> posts.

New description:

 The PR proposes to extend `WP_REST_Posts_Controller` with a new route
 /count to fetch page counts, e.g., wp/v2/pages/count.

 The total number of post counts is fetched by using
 [https://developer.wordpress.org/reference/functions/wp_count_posts/
 wp_count_posts].

 https://github.com/WordPress/gutenberg/pull/67719

 There is a need for a performant post counts check in the block editor.
 See:
 https://github.com/WordPress/gutenberg/pull/65223#issuecomment-2381323815

 Contrast this feature with `$query->found_posts` which returns the total
 count for a specific query only and would degrade performance given `n`
 posts.

--

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


More information about the wp-trac mailing list