LoginSignup
9
9

More than 5 years have passed since last update.

【WordPress】アドバンスカスタムフィールドでチェックボックスなどの複数の値を検索するとき

Last updated at Posted at 2014-07-12

コード

hoge.php
foreach($borrow as $val){
  $borrow_set = array(
    'key' => 'search_0_borrow',
    'value' => '"'.$val.'"',
    'compare' => 'LIKE'
  );
}

if (count($borrow) > 1) {$borrow_set['relation'] = 'AND';}

複数の値はDBにa:3:{i:0;s:1:”1”;i:1;s:3:”155”;i:2;s:3:”156”;}こんな感じで送られてしまうらしい。
'compare' => 'LIKE'でキーワード検索をかけるといいみたい。
値が複数の時はANDを追加する。

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9