How to prevent custom fields from being cleared during a bulk edit?

You can check for a bulk edit by looking at the bulk_edit variable in $_GET or $_POST. Bulk edits are typically GET requests as far as I investigated them.

Note that $_REQUEST takes both GET and POST data into account. In wp-admin/edit.php they also do an isset() check for $_REQUEST['bulk_edit'].

function save_my_post($post_id)
{
    // Do nothing during a bulk edit
    if (isset($_REQUEST['bulk_edit']))
        return;

    // ...
}

Leave a Comment