admin管理员组文章数量:1415636
I am having this problem where every time I run this, it stops on page 3. There are about 15000 products that are published. So there should be at least 30 pages.
I narrowed it down to the $loop = new WP_Query( $args ) just stopping for some reason. Not sure how to figure out what the error is.
function processPerPage($paged, $i) {
if($paged) { } else { $paged = 1; }
$args = array(
'post_type' => 'product',
'posts_per_page' => 500,
'paged' => $paged
);
$loop = new WP_Query( $args );
if($i) { } else { $i = 1; }
while ( $loop->have_posts() ) {
// do product work
$i++;
}
wp_reset_query();
}
global $wpdb;
$count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_type = 'product' and post_status = 'publish'" );
$pagestotal = $count/500+1;
$paged = 1;
while($paged <= $pagestotal) {
processPerPage($paged, $i);
$paged++;
}
本文标签: phpPaged WPQuery is quitting on page 3
版权声明:本文标题:php - Paged WP_Query is quitting on page 3 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745241567a2649356.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论