0
返回0試圖實現在WordPress的自定義分頁,我不能得到職位的數量來動態創建分頁元素。計數WP_Query在WordPress的
$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.1
循環只包含第一個X的帖子。不是所有的人。 – Tasos