[wp-trac] [WordPress Trac] #42409: Add LIKE support to meta_key comparisons in WP_Meta_Query

WordPress Trac noreply at wordpress.org
Wed Feb 28 12:59:48 UTC 2018


#42409: Add LIKE support to meta_key comparisons in WP_Meta_Query
-------------------------------------------------+-------------------------
 Reporter:  Otto42                               |       Owner:
     Type:  enhancement                          |  mariovalney
 Priority:  normal                               |      Status:  assigned
Component:  Query                                |   Milestone:  Awaiting
 Severity:  normal                               |  Review
 Keywords:  good-first-bug has-patch has-unit-   |     Version:  4.9
  tests 2nd-opinion                              |  Resolution:
                                                 |     Focuses:
-------------------------------------------------+-------------------------

Comment (by mariovalney):

 Thanks for the cleanup, @boonebgorges !

 About the "escape_wildcards_key" I've been thinking about the alternative
 using a filter to avoid a new field. But I'm concerned about a misuse to
 break all LIKE WP_Queries and/or being a lot verbose to use it for a
 unique WP_Query call.

 About the others operators ('NOT LIKE','IN', 'NOT IN','EXISTS', 'NOT
 EXISTS') I guess we should work in another ticket as enhancement we should
 talk about the use cases. For example, if we do:

 {{{#!php
 <?php
 'meta_query' => array(
     array(
         'key'           => 'foo',
         'compare_key'   => 'NOT EXISTS',
     ),
 ),
 }}}


 Will return all posts, if we just add the parameter "as it's" (in
 meta_value cases). Because every post has at least one [core] meta_key
 that it's different from "foo".

 To create a way to consult if the meta_key foo is not presented we should
 do a little more code.

 (I guess this last point answer the second question: no reason to hold
 it.)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42409#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list