Support » Plugin: Custom Content Type Manager » GetPostsQuery operator like

  • Hi. I came across with such difficulty. I am trying to search by custom field, for example color. I am using GetPostsQuery class. I want to use “like” operator –

    $args['meta_key'] = 'color'
     $args['meta_value']['like'] = 'blue'

    But here like operator works as equal operator. I want to find out why.
    I want this query to bring not only blue colors, but also light-blue.
    Also if my field is multi-select, I have to write
    $args['meta_value'] = '["blue", "red"]'
    to get the result I want. But there must be another way, or maybe I am doing something wrong. Please help me with this.

    I am using clean wordpress on the default theme, with no other plugins installed.

Viewing 1 replies (of 1 total)
  • Plugin Contributor fireproofsocks


    Did you forget some semi-colons there?

    You can use the debug option to print out the SQL query — that’s usually the best way to compare the arguments you use to the query that’s generated.

    The multi-fields are stored as JSON encoded arrays. This is intentional — you can read the wiki about why I chose to do it that way. I felt the pros outweighed the cons, but it does mean you may need to include double-quotes in some of your search terms.

Viewing 1 replies (of 1 total)
  • The topic ‘GetPostsQuery operator like’ is closed to new replies.