I too am looking for this option / feature. I came across this guys explanation which I believe answers most of the question. I am in the process of implementing this so I cannot say how accurate it is being a wordpress noob (not php!), I do realise this is for a custom box but you could populate the column field using the the_excerpt()
fn or from the $post object – etc.
So it seems, to have the option we want available in the quick edit section, we need to add it as a “custom” column in the post / page list view first.
/*
* New columns
*/
add_filter('manage_post_posts_columns', 'misha_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['featured'] = 'Featured product';
return $column_array;
}
/*
* Populate our new columns with data
*/
add_action('manage_posts_custom_column', 'misha_populate_column', 10, 2);
function misha_populate_column( $column_name, $id ) {
switch( $column_name ) :
case 'featured': {
if( get_post_meta($id,'product_featured',true) == 'on')
echo 'Yes';
break;
}
endswitch;
}
Then we can add it to the quick edit section.
/*
* quick_edit_custom_box allows to add HTML in Quick Edit
* Please note: it files for EACH column, so it is similar to manage_posts_custom_column
*/
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 'featured': {
echo '<fieldset><label class="alignleft">
<input type="checkbox" name="featured">
<span class="checkbox-title">Featured product</span>
</label></fieldset>';
break;
}
endswitch;
}
We also need some code to hook into save post to allow for updating the meta data.
/*
* Quick Edit Save
*/
add_action( 'save_post', 'misha_quick_edit_save' );
function misha_quick_edit_save( $post_id ){
if ( !current_user_can( 'edit_post', $post_id ) ) {
return;
}
if ( !wp_verify_nonce( $_POST['misha_nonce'], 'misha_q_edit_nonce' ) ) {
return;
}
if ( isset( $_POST['featured'] ) ) {
update_post_meta( $post_id, 'product_featured', 'on' );
} else {
update_post_meta( $post_id, 'product_featured', '' );
}
}
Lastly some JavaScript, he uses jQuery, is required to populate the fields data once the page is loaded. This he places in a separate file and loads with wp_enqueue:
add_action( 'admin_enqueue_scripts', 'misha_enqueue_quick_edit_population' );
function misha_enqueue_quick_edit_population( $pagehook ) {
// do nothing if we are not on the target pages
if ( 'edit.php' != $pagehook ) {
return;
}
wp_enqueue_script( 'populatequickedit', get_stylesheet_directory_uri() . '/populate.js', array( 'jquery' ) );
}
JavaScript file:
jQuery(function($){
var wp_inline_edit_function = inlineEditPost.edit;
inlineEditPost.edit = function( post_id ) {
wp_inline_edit_function.apply( this, arguments );
var id = 0;
if ( typeof( post_id ) == 'object' ) { // if it is object, get the ID number
id = parseInt( this.getId( post_id ) );
}
if ( id > 0 ) {
// add rows to variables
var specific_post_edit_row = $( '#edit-' + id ),
specific_post_row = $( '#post-' + id ),
featured_product = false; // let's say by default checkbox is unchecked
if( $( '.column-featured', specific_post_row ).text() == 'Yes' ) featured_product = true;
$( ':input[name="featured"]', specific_post_edit_row ).prop('checked', featured_product );
}
}
});
I’ve copy, pasted & edited his raw code for reference, the tutorial at the site has comments within in the code explaining its use etc. I don’t know this person just came across this post and theirs whilst googling.
Finally one thing I believe may need pointing out is that the save_post hook could interfere with any hooks you already have for save_post and I am unsure if quick edit save_post would recognise the excerpt field as standard or would need the hook above?!