由于我们没有为此蒙皮或使用标准模板,我们遇到了一些困难,但我们在项目中走得太远,无法回头。我从来没有这样做过WP\\U查询,但有两件事可以概括它的结构。
我正在查询帖子类型tribe_events
其中postmeta密钥等于_VenueCity
, _VenueState
, 和_VenueCountry
和值等于GET/POST请求tribe_venue 分类法使我很难直接查询Posteta,因为它没有直接连接到tribe_events
岗位类型
<?php
// Support for multiple locations to be filtered.
$request_cities = array_map(function($item){return utf8_decode(urldecode($item));}, explode(\'+\', $_REQUEST[\'city\']));
$request_states = array_map(function($item){return utf8_decode(urldecode($item));}, explode(\'+\', $_REQUEST[\'state\']));
$request_countries = array_map(function($item){return utf8_decode(urldecode($item));}, explode(\'+\', $_REQUEST[\'country\']));
// If the event only has 1 item convert to string.
if (is_array($request_cities) && count($request_cities) <= 1) {
$request_cities = implode("|", $request_cities);
}
if (is_array($request_states) && count($request_states) <= 1) {
$request_states = implode("|", $request_states);
}
if (is_array($request_countries) && count($request_countries) <= 1) {
$request_countries = implode("|", $request_countries);
}
$event_args = [];
$event_args[\'meta_query\'] = [
[
\'key\' => \'_VenueCity\',
\'value\' => $request_cities
], [
\'key\' => \'_VenueState\',
\'value\' => $request_states
], [
\'key\' => \'_VenueCountry\',
\'value\' => $request_countries
],
\'relation\' => \'AND\'
];
$event_args[\'tax_query\'] = [
[
\'taxonomy\' => \'tribe_venue\',
\'field\' => \'term_id\',
\'terms\' => $request_cities
]
];
$events = tribe_get_events($event_args);
?>
如果有人能帮我弄明白这一点,我将不胜感激,因为我花了这么多时间试图弄明白这一点。