search in custom field if custom field is an array (4 posts)

  1. slee
    Posted 5 years ago #

    i am using meta_value to search a custom field with a key of species
    The way the data is stored is in an array how can i still use meta_value and be able to find the posts with dog for example?

  2. MichaelH
    Posted 5 years ago #

    Use query_posts or get_posts with arguments such as

      'showposts' => -1,
      'meta_key' => 'species',
      'meta_value' => 'elephantopus ',
      'meta_compare' => '='
  3. slee
    Posted 5 years ago #

    unfortunately i tried that with no joy it returns nothing.

    this is how the data is stored:
    a:11:{i:0;s:16:"Air Conditioning";i:1;s:10:"Dishwasher";i:2;s:
    9:"Fireplace";i:3;s:15:"Hardwood Floors";i:4;s:20:"Over-Range
    Microwave";i:5;s:10:"Waterfront";i:6;s:12:"Deck / Patio";i:7;s:

    The above code is not my exact code only what i found on the flutter website.
    i am using Flutter to input the data.

    the meta_value works fine for my other custom fields but on this one with the array it does not.

  4. scribu
    Posted 5 years ago #

    Storing custom fields as serialized arrays is a bad ideea precisely because it's hard to search through them afterwards.

    Flutter should store each value separately.

Topic Closed

This topic has been closed to new replies.

About this Topic