Make WordPress Core


Ignore:
Timestamp:
02/07/2023 08:53:01 AM (18 months ago)
Author:
audrasjb
Message:

Query: Add a search_columns argument to control which fields are searched in a search query.

Previously, the s argument of the WP_Query::parse_query() method searched the post_title, post_excerpt, and post_content fields, with no way of controlling this apart from using the posts_search filter and adjusting the SQL manually. This changeset adds the ability to specify which fields are searched when performing a query, using the search_columns argument.

Props johnbillion, birgire, petitphp, audrasjb, costdev, mukesh27.
Fixes #43867.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php

    r55210 r55248  
    148148        $this->assertArrayHasKey( 'per_page', $properties );
    149149        $this->assertArrayHasKey( 'search', $properties );
     150        $this->assertArrayHasKey( 'search_columns', $properties );
    150151        $this->assertArrayHasKey( 'slug', $properties );
    151152        $this->assertArrayHasKey( 'status', $properties );
Note: See TracChangeset for help on using the changeset viewer.