0
請有人可以告訴我我的代碼錯了嗎?雖然循環與陣列推get_field ACF插件不能正常工作
循環不起作用。
當我這樣做時,整個頁面都是空白的。
function filter_reports() {
global $customer_account;
$args = array(
'post_type' => 'ebooks',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'customer',
'field' => 'term_id',
'terms' => $customer_account,
),
array(
'taxonomy' => 'disease',
'field' => 'term_id',
'terms' => $_POST['options'],
)
),
);
$the_query = new WP_Query($args);
$results = array();
if ($the_query->have_posts()) {
while ($the_query->have_posts()) {
$id = get_the_ID();
array_push($results, array(
'id' => $id,
'title' => get_field('title', $id),
'chair' => get_field('e-chair', $id),
));
}
}
echo json_encode($results);
die;
}
add_action('wp_ajax_filter_reports', 'filter_reports');
add_action('wp_ajax_nopriv_filter_reports', 'filter_reports');
我想讓我在ACF插件中製作的自定義字段在我的while循環中循環。 但是整個WHILE不工作。
我真的希望有人能幫助我。
我想(不是一個WP專家),你寫了一個無限的while循環那裏 – RiggsFolly
我該怎麼辦?我陷入困境。 – Dionoh
在實際嘗試使用結果集的while循環中使用調用,而不是隻詢問結果集中是否有任何內容的調用 – RiggsFolly