1
在PODS中,我創建了一個新的定製分類標準,並且啓用了額外的字段(因此它創建了一個新的數據庫表:wp_pods_taxname
)。在PODS分類定製表字段中搜索
如何根據$search
字符串搜索此表格內部並返回屬於已發現分類法的所有帖子?
我開始這樣做,但只有意識到它不能正常工作,它可能在錯誤的地點進行搜索:
$args = array(
'post_type' => 'book',
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'author',
'field' => 'first_name',
'terms' => $search,
'operator' => 'LIKE'
),
array(
'taxonomy' => 'author',
'field' => 'last_name',
'terms' => $search,
'operator' => 'LIKE'
),
)
);
$query = new WP_Query($args);
任何幫助,將不勝感激!
實例分類:
- 作者,表存儲屬性:
- 名
- 姓
- 生日
實例後類型:
- 書籍,可以分配到一個分類(作者)
我希望能夠搜索按名字,姓氏,或生日所有的作者 - 搜索字符串中$search
之中。然後,我希望能夠顯示所有書籍。所以,如果$search
= 「哈珀」,我應該看到的書:
- 殺死一隻知更鳥
- 設立守望者
更新,
所以,我能夠取得一些進展...但仍然返回0結果。更新查詢:
$pods = pods('review');
$search = $wpdb->esc_like($search);
$params = array(
'where' => array(
'relation' => 'OR',
array(
'value' => $search,
'key' => 'customer.d.first_name',
'compare' => 'LIKE'
),
array(
'key' => 'customer.d.last_name',
'value' => $search,
'compare' => 'LIKE'
)
)
);
$res = $pods->find($params);
var_dump($res);
產量: 選擇
DISTINCT
`t`.*
FROM `wpcc_posts` AS `t`
LEFT JOIN `wpcc_term_relationships` AS `rel_customer` ON
`rel_customer`.`object_id` = `t`.`ID`
LEFT JOIN `wpcc_term_taxonomy` AS `rel_tt_customer` ON
`rel_tt_customer`.`taxonomy` = 'customer'
AND `rel_tt_customer`.`term_taxonomy_id` = `rel_customer`.`term_taxonomy_id`
LEFT JOIN `wpcc_terms` AS `customer` ON
`customer`.`term_id` = `rel_tt_customer`.`term_id`
LEFT JOIN `wpcc_pods_customer` AS `customer_d` ON
`customer_d`.`id` = `customer`.`term_id`
WHERE ((((`customer_d`.`first_name` LIKE "%Jon%") OR (`customer_d`.`last_name` LIKE "%Jon%"))) AND (`t`.`post_type` = "review") AND (`t`.`post_status` IN ("publish"))) AND (`t`.`post_title` LIKE '%Jon^%')
ORDER BY `t`.`menu_order`, `t`.`post_title`, `t`.`post_date`
LIMIT 0, 15`
在我而言, 「客戶」=帶自定義字段分類,和 「評論」 分配到分類=崗位類型。我覺得這很接近。哎。