맞춤식 분류를위한 데이터가있는 json 파일이 있습니다. 그리고 필터를해야합니다. 포스트 메타 링크와 다른 필드에 아무런 문제가 없습니다. 하지만 나는 카테고리를 json으로 가져올 수 없습니다. 그런 다음 필터링 할 수 없습니다.사용자 정의 게시물 가져 오기
나는 대답이 매우 간단해야하지만 나는 2 일 동안 그것을 이해할 수 없다는 것을 알고있다.
function getItems($meta_query) {
$params = array(
'post_type' => 'property',
'nopaging' => true,
'post_status' => 'publish',
'meta_query' => array(),
$meta_query = array('meta_query'=>array(), 'relation' => 'AND');
if (!empty($_POST['city']))
{
$params['meta_query'][] =array(
'key' => 'property_city',
'value' => $_POST['city'],
'compare' => 'LIKE'
);
}
if(!empty($_POST['parish']))
{
$params['meta_query'][] = array(
'key' => 'property_state',
'value' => $_POST['parish'],
'compare' => 'LIKE'
);
}
//..................ETC..........................
내가 지금 범주에 대해 무엇을 가지고 :
//if (!empty($_POST['category']))
/*{
$params['meta_query'][] = array(
'taxonomy' => 'pcategory',
'field' => 'slug',
'terms' => $_POST['category']->slug
);
}*/
$itemsQuery = new WP_Query();
$properties = $itemsQuery -> query($params);
// add property details
foreach ($properties as $key => $property) {
// options
$property->optionsDir = get_post_meta($property->ID, 'property', true);
$city = get_post_meta($property->ID, 'property_city', true);
$parish = get_post_meta($property->ID, 'property_state', true);
$link = get_permalink($property->ID);
$category = get_the_terms($property->ID,'pcategory');
$properties[$key]->link = array(
'link' => $link,
);
//postmeta
$properties[$key]->postmeta = array(
'city' => $city,
'parish' => $parish,
'region' => $region,
'link' => $link,
'category' => $category,
);
}
return $properties;
}
고마워 .. 나는 그랬다. 내가 뭘 잘못했는지는 모르겠지만 파이어 버그의 콘솔은 json 카테고리 배열에 [ "잘못된 분류법"]을 쓰려고 멈추지 않습니다. – user3727355