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