Commit 3b7536d5ba for wordpress.org
commit 3b7536d5ba18ccbda4b62fa6a620488513989afe
Author: wildworks <wildworks@git.wordpress.org>
Date: Fri Dec 4 13:09:24 2026 +0000
REST API: Add `excerpt_length` to post collection endpoints.
Registers the `excerpt_length` parameter on post collection endpoints, for post types that support excerpts, with the same definition as the single post endpoint. Requests that list several posts can now ask for an excerpt at a given length through a documented and validated parameter, without filtering the excerpt length globally.
Developed in https://github.com/WordPress/wordpress-develop/pull/16511
Follow-up to [58065].
Props swissspidy, wildworks.
Fixes #66940.
Built from https://develop.svn.wordpress.org/trunk@65918
git-svn-id: http://core.svn.wordpress.org/trunk@64947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
index a333b55845..cf7be1d53a 100644
--- a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
+++ b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
@@ -3016,6 +3016,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
* @since 4.7.0
* @since 5.4.0 The `tax_relation` query parameter was added.
* @since 5.7.0 The `modified_after` and `modified_before` query parameters were added.
+ * @since 7.3.0 The `excerpt_length` query parameter was added.
*
* @return array Collection parameters.
*/
@@ -3209,6 +3210,14 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
);
}
+ $schema = $this->get_item_schema();
+ if ( isset( $schema['properties']['excerpt'] ) ) {
+ $query_params['excerpt_length'] = array(
+ 'description' => __( 'Override the default excerpt length.' ),
+ 'type' => 'integer',
+ );
+ }
+
/**
* Filters collection parameters for the posts controller.
*
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 6727e5ac14..76c296b291 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.3-alpha-65916';
+$wp_version = '7.3-alpha-65918';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.