PHP code example of versusbassz / wp-batcher
1. Go to this page and download the library: Download versusbassz/wp-batcher library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
versusbassz / wp-batcher example snippets
$paged = 1;
wp_suspend_cache_addition( true );
while ( true ) {
$items = get_posts( [
'posts_per_page' => 100,
'paged' => $paged,
'orderby' => 'ID',
'order' => 'ASC',
] );
if ( ! count( $items ) ) {
break;
}
foreach ( $items as $item ) {
// Payload
}
++$paged;
}
wp_suspend_cache_addition( false );
use \Versusbassz\WpBatcher\WpBatcher;
$iterator = WpBatcher::get_posts();
foreach ( $iterator as $item ) {
// Payload
}