-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Hi,
I am trying with simple delete post like this, but the batch keep running even reach 100%...
Please check that...!
public function setup() {
$posts = get_posts( array(
'numberposts' => 10,
'post_type' => 'it24-serial-number'
) );
foreach ( $posts as $post ) {
$this->push( new WP_Batch_Item( $post->ID, array( 'post_id' => $post->ID ) ) );
}
}
public function process( $item ) {
// Retrieve the custom data
$post_id = $item->get_value( 'post_id' );
// Return WP_Error if the item processing failed (In our case we simply skip author with user id 5)
// if ( $post_id != 5 ) {
// return new WP_Error( 302, "ID".$post_id );
// }
// Do the expensive processing here. eg. Sending email.
// ...
**wp_trash_post($post_id);**
// Return true if the item processing is successful.
return true;
}
/**
* Called when specific process is finished (all items were processed).
* This method can be overriden in the process class.
* @return void
*/
public function finish() {
// Do something after process is finished.
// You have $this->items, or other data you can set.
}
}
Metadata
Metadata
Assignees
Labels
No labels