Custom Fields in Quick Edit
In this tutorial I will show you how to add any custom fields to WordPress quick edit. As an example we are going to add a simple text field and a checkbox.

1. Create a Column for Every Custom Field
At this moment you might say that you didn’t have any plans to overload your admin pages with custom columns.
Please do not worry about it, because anyway it is always possible to hide specific columns in “Screen Options”. If the columns are hidden, it doesn’t affect quick edit functionality anyway.

// add new columns
add_filter( 'manage_post_posts_columns', 'misha_price_and_featured_columns' );
// the above hook will add columns only for default 'post' post type, for CPT:
// manage_{POST TYPE NAME}_posts_columns
function misha_price_and_featured_columns( $column_array ) {
$column_array[ 'price' ] = 'Price';
$column_array[ 'featured' ] = 'Featured product';
// the above code will add columns at the end of the array
// if you want columns to be added in another order, use array_slice()
return $column_array;
}
// Populate our new columns with data
add_action( 'manage_posts_custom_column', 'misha_populate_both_columns', 10, 2 );
function misha_populate_both_columns( $column_name, $post_id ) {
// if you have to populate more that one columns, use switch()
switch( $column_name ) {
case 'price': {
$price = get_post_meta( $post_id, 'product_price', true );
echo $price ? '$'.$price : '';
break;
}
case 'featured': {
echo get_post_meta( $post_id, 'product_featured', true );
break;
}
}
}
- Most of the code from this tutorial you can add to your current theme
functions.php
file or create a plugin for that. - There is also another tutorial where we added Featured images in quick edit, check it out.
2. Adding Fields to Quick Edit
The first thing you should know is that action hook quick_edit_custom_box
is fired for every column, so that makes it a little tricky to display the HTML of the whole field group.
I mean I think it would be a really great idea to wrap all the fields into a single <fieldset>
element. The only idea I have here is to add an opening <fieldset>
tag when displaying the first field in a group and a closing </fieldset>
tag when displaying the last one.
<?php
// quick_edit_custom_box allows to add HTML in Quick Edit
add_action( 'quick_edit_custom_box', 'misha_quick_edit_fields', 10, 2 );
function misha_quick_edit_fields( $column_name, $post_type ) {
switch( $column_name ) {
case 'price': {
?>
<fieldset class="inline-edit-col-left">
<div class="inline-edit-col">
<label>
<span class="title">Price</span>
<input type="text" name="price">
</label>
</div>
<?php
break;
}
case 'featured': {
?>
<div class="inline-edit-col">
<label>
<input type="checkbox" name="featured"> Featured product
</label>
</div>
</fieldset>
<?php
break;
}
}
}
Once finish this step, the fields should appear in your Quick Edit. Do not worry if the fields are empty, we will populate them in the next steps of this tutorial.
3. Save Quick Edit Fields
Just using WordPress save_post
hook here and believe me it is the only one we can use.
// save fields after quick edit
add_action( 'save_post', 'misha_quick_edit_save' );
function misha_quick_edit_save( $post_id ){
// check inlint edit nonce
if ( ! wp_verify_nonce( $_POST[ '_inline_edit' ], 'inlineeditnonce' ) ) {
return;
}
// update the price
$price = ! empty( $_POST[ 'price' ] ) ? absint( $_POST[ 'price' ] ) : 0;
update_post_meta( $post_id, 'product_price', $price );
// update checkbox
$featured = ( isset( $_POST[ 'featured' ] ) && 'on' == $_POST[ 'featured' ] ) ? 'yes' : 'no';
update_post_meta( $post_id, 'product_featured', $featured );
}
After this step when you click «Update» button, the Quick Edit fields should be updated in your custom columns.
4. Populate the Fields using Columns Data
You can create any custom JavaScript file in your theme and add the code below there. Or you can also use admin_footer
hook.
jQuery( function( $ ){
const wp_inline_edit_function = inlineEditPost.edit;
// we overwrite the it with our own
inlineEditPost.edit = function( post_id ) {
// let's merge arguments of the original function
wp_inline_edit_function.apply( this, arguments );
// get the post ID from the argument
if ( typeof( post_id ) == 'object' ) { // if it is object, get the ID number
post_id = parseInt( this.getId( post_id ) );
}
// add rows to variables
const edit_row = $( '#edit-' + post_id )
const post_row = $( '#post-' + post_id )
const productPrice = $( '.column-price', post_row ).text().substring(1) // remove $ sign
const featuredProduct = 'yes' == $( '.column-featured', post_row ).text() ? true : false;
// populate the inputs with column data
$( ':input[name="price"]', edit_row ).val( productPrice );
$( ':input[name="featured"]', edit_row ).prop( 'checked', featuredProduct );
}
});

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
Hello, Misha.
Is quick edit default feature in wordpress? Because i don`t have that link in posts section of adminarea, only standart edit, and that`s after adding 2 custom columns.
Thank you for answer and have a nice holidays.
Hey Andrey,
Yes, it is the default feature. It should be on your posts page even without implementing anything from this tutorial.
I suppose it was removed earlier by one of the plugins you use or by a custom hook in the
functions.php
file.Have nice holidays too 🙃
Hello Misha, thank you for great tutorial. Do you know how to make custom column that show product weight with sort on products page in woocommerce?
Something like this: https://prnt.sc/i40rv8
This is the plugin “Order Weight for WooCommerce” but this is not work anymore. Only show column but not weight of product.
Hey Kamil,
I will publish a tutorial about it on the next Tuesday.
Hey Misha,
that’s awesome!
I’m happy that I found your blog. You provide a lot of valuable information.
Thank you for what you do. I’m looking forward.
You’re welcome! 🙂
Thanks Misha you save my life. :D
Does it work with ACF plugin ?
Yes
Neat tutorial Misha.
Actually I reached this post while I was looking for something else,
Is there a way to add quick edit to users.php page?
I think the main problem is no
inline_edit
method defined inWP_Users_List_Table
class to fire a action hook likequick_edit_custom_box
that we have on posts and terms table classes. I’m thinking about hijackinguser_row_actions
filter hook. What’s your idea on this?And I know hijacking the whole table class is one other dirty solution for this :/
Hello Misha,
for me as a beginner this tut was a bit too hard, because I tried to apply it for the custom post excerpt and I had problems. Can you do a tut for the excerpt or provide me with the code? That would be so helpful.
Thank you
Hello,
I will add it to my “Tut ideas” list
Thanks!