I’ve used add_meta_box() to add a custom meta box to the WordPress edit window on both pages and posts.
How can I make this meta box also show on the “Quick Edit” screen?
Ideally, I’d like it to appear just to the right of the Categories selector.
I’ve used add_meta_box() to add a custom meta box to the WordPress edit window on both pages and posts.
How can I make this meta box also show on the “Quick Edit” screen?
Ideally, I’d like it to appear just to the right of the Categories selector.
There seems to be no easy way to do this, you must add all code yourself. inline_edit_row()
, the function that draws the Quick Edit and Bulk Edit screens, seems to have only one action that you can hook into: quick_edit_custom_box
or bulk_edit_custom_box
. It gets called for all non-core columns that wp_manage_posts_columns()
returns. There are some filters you can use to add a column, for example manage_posts_columns
. Unfortunately, this function defines the column headers of the post table, so you should remove it again before print_column_headers()
prints them. This can be done in the get_column_headers()
function, with the manage_[screen_id]_headers
filter. edit-post
is the screen id for the Edit Posts screen.
All together, this gives a hack like the following to add some code. Finding out where you can handle the form submission is (currently) left as a exercise to the reader.
// Add a dummy column for the `posts` post type
add_filter('manage_posts_columns', 'add_dummy_column', 10, 2);
function add_dummy_column($posts_columns, $post_type)
{
$posts_columns['dummy'] = 'Dummy column';
return $posts_columns;
}
// But remove it again on the edit screen (other screens to?)
add_filter('manage_edit-post_columns', 'remove_dummy_column');
function remove_dummy_column($posts_columns)
{
unset($posts_columns['dummy']);
return $posts_columns;
}
// Add our text to the quick edit box
add_action('quick_edit_custom_box', 'on_quick_edit_custom_box', 10, 2);
function on_quick_edit_custom_box($column_name, $post_type)
{
if ('dummy' == $column_name) {
echo 'Extra content in the quick edit box';
}
}
// Add our text to the bulk edit box
add_action('bulk_edit_custom_box', 'on_bulk_edit_custom_box', 10, 2);
function on_bulk_edit_custom_box($column_name, $post_type)
{
if ('dummy' == $column_name) {
echo 'Extra content in the bulk edit box';
}
}