Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: rest_query_var-{$key}

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
505       * @param array           $prepared_args Optional. Prepared WP_Query arguments. Default empty array.
506       * @param WP_REST_Request $request       Optional. Full details about the request.
507       * @return array Items query arguments.
508       */
509      protected function prepare_items_query( $prepared_args = array(), $request = null ) {
510           $query_args = array();
511
512           foreach ( $prepared_args as $key => $value ) {
513                /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */
514                $query_args[ $key ] = apply_filters( "rest_query_var-{$key}", $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
515           }
516
517           // Map to proper WP_Query orderby param.
518           if ( isset( $query_args['orderby'] ) && isset( $request['orderby'] ) ) {
519                $orderby_mappings = array(
520                     'id'            => 'ID',
521                     'include'       => 'post__in',
522                     'slug'          => 'post_name',
523                     'include_slugs' => 'post_name__in',