do_action( ‘bulk_edit_posts’, int[] $updated, array $shared_post_data )

Fires after processing the post data for bulk edit.

Parameters

$updatedint[]
An array of updated post IDs.
$shared_post_dataarray
Associative array containing the post data.

Source

do_action( 'bulk_edit_posts', $updated, $shared_post_data );

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

  1. Skip to note 2 content
    // Define a custom function to handle bulk edit
    function my_bulk_edit_posts_handler( $updated, $shared_post_data ) {
    	// Loop through the array of post IDs that have been updated
    	foreach ( $updated as $post_id ) {
    		// Perform custom actions on each post
    		// For example, you can update post content or metadata
    		$post_title  = get_the_title( $post_id );
    		$new_content = "Updated content for post: $post_title";
    
    		// Update post content
    		wp_update_post(
    			array(
    				'ID'           => $post_id,
    				'post_content' => $new_content,
    			)
    		);
    
    		// You can access $shared_post_data here as well if needed
    	}
    }
    
    // Hook the custom function to the 'bulk_edit_posts' action
    add_action( 'bulk_edit_posts', 'my_bulk_edit_posts_handler', 10, 2 );

You must log in before being able to contribute a note or feedback.