1
在WordPress是新手參考下面我的編碼,它沒有得到所有記錄:如何在wordpress中使用where條件獲取所有行?
post_author ='1' and post_type ='attachment'
這只是僅返回單行。在我的數據庫中有20行,其中:
post_author ='1' and post_type ='attachment'
這是我的PHP代碼:
<?php
$args = array('author' => '1' ,'post_type' => 'attachment');
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
// now $query->post is WP_Post Object, use:
echo $query->post->ID;
}
}
?>
沒有它也返回單行。 –
我已經更新了我的答案,請你檢查一下嗎? – purvik7373
是的,檢查,但沒有記錄獲得上述代碼? –