Allow LIKE queries against the 'key' value in meta queries.

The new `compare_key=LIKE` parameter works in conjunction with `key` in a
similar way to the `compare=LIKE` and `value`: by doing a "compares" `LIKE`
query. This allows developers to do partial matches against keys when
doing meta queries.

Props mariovalney, chasewg.
Fixes #42409.

git-svn-id: https://develop.svn.wordpress.org/trunk@42768 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2018-03-01 04:02:41 +00:00
parent 6e5a560be0
commit e840759df5
3 changed files with 110 additions and 15 deletions
+2
View File
@@ -604,6 +604,7 @@ class WP_Query {
* Introduced `RAND(x)` syntax for `$orderby`, which allows an integer seed value to random sorts.
* @since 4.6.0 Added 'post_name__in' support for `$orderby`. Introduced the `$lazy_load_term_meta` argument.
* @since 4.9.0 Introduced the `$comment_count` parameter.
* @since 5.0.0 Introduced the `$meta_compare_key` parameter.
*
* @param string|array $query {
* Optional. Array or string of Query parameters.
@@ -640,6 +641,7 @@ class WP_Query {
* @type int $m Combination YearMonth. Accepts any four-digit year and month
* numbers 1-12. Default empty.
* @type string $meta_compare Comparison operator to test the 'meta_value'.
* @type string $meta_compare_key Comparison operator to test the 'meta_key'.
* @type string $meta_key Custom field key.
* @type array $meta_query An associative array of WP_Meta_Query arguments. See WP_Meta_Query.
* @type string $meta_value Custom field value.