在那裏我想顯示我的數據。當我嘗試不postmeta其工作,以顯示我的數據,但是當我試圖用postmeta改善我得到的空白響應空白的迴應,當我想顯示postmeta WordPress的
$command = $_GET['command'];
switch ($command) {
case 'list_product':
$loop = new WP_Query(
array(
'post_type' => 'product'
// 'showposts' => 4,
// 'meta_key' => '_sale_price',
// 'meta_value' => '0',
// 'meta_compare' => '>=',
)
);
if($loop->have_posts()) :
$data = array("api_status" => 1, "api_message" => "success");
while ($loop->have_posts()) : $loop->the_post();
$data[] = array("id" => get_the_ID(),
"post_name" => get_the_title(),
"post_meta" => get_post_meta(get_the_ID());
endwhile;
echo json_encode($data);
break;
}
有人幫我什麼改善,我需要在我的代碼,所以我的代碼可以像我需要的那樣工作?
未定義索引時沒有結果。 – Walf
我不知道wordpress,但我在他的發言中看到了一個失蹤的「endif」。由於我的低點,我不能直接添加評論問題。 OP必須瞭解如何在第一時間啓用錯誤調試 –
我已經更新了我的答案..我真的不知道對那些自定義定義的wordpress方法有什麼期望,所以$ data []可以在while子句之內或之外。我試圖修復語法 –