Custom Fields in Bulk Edit
Not so many tutorials ago I published my tutorial about custom fields in quick edit. The current one is super-similar actually, but allows to add fields to Bulk actions – Edit.
Our goal here is to add a couple fields there (if you’re are looking for information about bulk actions, then it is a wrong tut for you, here is the right one).
That’s what we are going to create here:

1. Add a Column for Every Field
Actually we implemented the same thing completely in the Quick Edit tutorial, so please go there and copy the whole code from Step 1 to your current theme functions.php
file.
2. Using bulk_edit_custom_box to Make the Fields Appear in Bulk Edit
Another fun story is that you have to go to Quick Edit tutorial again and copy the whole function misha_quick_edit_fields()
from Step 2 of the tutorial. But you do not have to copy the action hook because we are going to use another one here.
add_action( 'bulk_edit_custom_box', 'misha_quick_edit_fields', 10, 2 );
3. Save Fields
That would be so funny guys, if I would ask you to copy one more step from the Quick Edit tut, but no. We are still going to use the same save_post
action hook but it is a little bit different here this time – we are going to use another nonce check and get form values from $_REQUEST
, not $_POST
. One more thing about nonce check – we are using bulk-posts
action here for Posts, for Pages it would be bulk-pages
etc.
add_action( 'save_post', 'misha_bulk_edit_save' );
function misha_bulk_edit_save( $post_id ){
// check bulk edit nonce
if ( ! wp_verify_nonce( $_REQUEST[ '_wpnonce' ], 'bulk-posts' ) ) {
return;
}
// update the price
$price = ! empty( $_REQUEST[ 'price' ] ) ? absint( $_REQUEST[ 'price' ] ) : 0;
update_post_meta( $post_id, 'product_price', $price );
// update checkbox
$featured = ( isset( $_REQUEST[ 'featured' ] ) && 'on' == $_REQUEST[ 'featured' ] ) ? 'yes' : 'no';
update_post_meta( $post_id, 'product_featured', $featured );
}
Of course if you’re adding custom fields to bulk edit and quick edit at the same time, you can make the function work for both of them.
That’s all, no JavaScript code this time.

Misha Rudrastyh
Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.
Need some developer help? Contact me
Hi,
Good tutorial thanks,
$featured in the line 18 of the last code have nothing to do with the code I guess
Hi,
Oh, yes, you’re right. Thank you! I’ve removed this line.
Hi, thanks for this great tutorial! But I have one question – if I need to add a number of custom fields (about 20), to bulk editor should I also add it to admin columns? As I understand from your quick edit tutorial this is required action, but if I add each of my 20 fields to admin columns it will look weird and it will be hard to use. Can you clarify, please?
Hey,
Columns are needed to prefill the quick edit input fields. So, bulk edit should work without columns too.
Great tutorial but…
async line in ajax call is depratched – should be removed
also the bulk edit is not populating field with current data, should it not populate data if the fields selected has the same value at least?
Hey Yngve,
Thank you, the line has been removed.
I think in WordPress it is not supposed to populate fields while bulk edit. Because the empty fields are not going to be updated.
Hello Misha, bulk save ajax not working in Firefox. Pege reloaded before ajax request runs.
Thank you man!
Dude, thank you!
Saved me a lot of time…
This was really helpful, thank you!
Hi Misha,
Great tutorial thankyou! I am using this to update 2 custom text fields and a checkbox field on WC Products. For some reason if the text fields are left empty, it is updating those fields to be empty and not ignoring them. Any idea what may be causing such behaviour? Also, if I input decimal numbers into the text fields, it is rounding them to the nearest integer.
Appreciate all that you do! :)