mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-20 19:56:49 +01:00
REST API: Add support for the ignore_sticky_posts argument.
Introduce `ignore_sticky` as a boolean argument for the posts endpoint for requests without the sticky posts being stuck. The new argument defaults to `false` with the value of the argument passed to `WP_Query`'s `ignore_sticky_posts` parameter. Props audrasjb, danielbachhuber, joemcgill, johnbillion, jorbin, mamaduka, rmccue. Fixes #35907. Built from https://develop.svn.wordpress.org/trunk@59801 git-svn-id: http://core.svn.wordpress.org/trunk@59143 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0ac2a96887
commit
d4822bd3c5
|
|
@ -247,6 +247,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'author_exclude' => 'author__not_in',
|
||||
'exclude' => 'post__not_in',
|
||||
'include' => 'post__in',
|
||||
'ignore_sticky' => 'ignore_sticky_posts',
|
||||
'menu_order' => 'menu_order',
|
||||
'offset' => 'offset',
|
||||
'order' => 'order',
|
||||
|
|
@ -337,6 +338,14 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Honor the original REST API `post__in` behavior. Don't prepend sticky posts
|
||||
* when `post__in` has been specified.
|
||||
*/
|
||||
if ( ! empty( $args['post__in'] ) ) {
|
||||
unset( $args['ignore_sticky_posts'] );
|
||||
}
|
||||
|
||||
if (
|
||||
isset( $registered['search_semantics'], $request['search_semantics'] )
|
||||
&& 'exact' === $request['search_semantics']
|
||||
|
|
@ -3045,6 +3054,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'description' => __( 'Limit result set to items that are sticky.' ),
|
||||
'type' => 'boolean',
|
||||
);
|
||||
|
||||
$query_params['ignore_sticky'] = array(
|
||||
'description' => __( 'Whether to ignore sticky posts or not.' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
);
|
||||
}
|
||||
|
||||
if ( post_type_supports( $this->post_type, 'post-formats' ) ) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.8-alpha-59800';
|
||||
$wp_version = '6.8-alpha-59801';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user