Wordpressでカスタムページネーションを実装しようとしましたが、ページング数を取得してページング要素を動的に作成できません。Count WP_QueryがWordpressで0を返します
$loop = new WP_Query(
array(
'post_type' => 'product',
'post_status ' => 'publish',
'orderby' => 'post_date',
'order' => 'date',
'posts_per_page' => $per_page,
'offset' => $start,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $suv_cates
)
)
)
);
$count = new WP_Query(
array(
'post_type' => 'product',
'post_status ' => 'publish',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $suv_cates
)
)
)
);
return $count->post_count;
$loop
の最初のクエリは、必要な投稿を返します。しかし、$count
または$count->post_count
を返すと0が返されます。
ループには最初のx個の投稿のみが含まれています。それらのすべてではありません。 – Tasos