Make WordPress Core


Ignore:
Timestamp:
09/11/2022 09:10:31 PM (2 years ago)
Author:
TimothyBlynJacobs
Message:

REST API: Add support for searching resources by id.

This brings support for the include and exclude collection parameters to the Search Controller. This can be used to find an item by id when it's subtype is unknown.

Props kadamwhite.
Fixes #56546.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php

    r53676 r54123  
    7070        }
    7171
     72        if ( ! empty( $request['exclude'] ) ) {
     73            $query_args['post__not_in'] = $request['exclude'];
     74        }
     75
     76        if ( ! empty( $request['include'] ) ) {
     77            $query_args['post__in'] = $request['include'];
     78        }
     79
    7280        /**
    7381         * Filters the query arguments for a REST API search request.
Note: See TracChangeset for help on using the changeset viewer.