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

Fires after processing the post data for bulk edit.


Parameters

$updated int[]
An array of updated post IDs.
$shared_post_data array
Associative array containing the post data.

Top ↑

Source

File: wp-admin/includes/post.php. View all references

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


Top ↑

Changelog

Changelog
Version Description
6.3.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Huzaifa Al Mesbah
    // 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.