Show Custom Fields in Quick Edit

I have several custom fields that I need my client to be able to edit at anytime. For the sake of convenience, I’d like them to be able to edit these custom fields from the Quick Edit. This way they don’t have to open a bunch of new pages to go into each post.

Is it possible to add editable custom fields to Quick Edit? Or am I out of luck?

2

After adding our custom column, we are ready to expand our Post Quick Edit menu using the quick_edit_custom_box action hook.

Note – The quick_edit_custom_box action hook will not fire unless there are custom columns present. That is why we started by adding a custom column.

add_action('quick_edit_custom_box',  'shiba_add_quick_edit', 10, 2);

function shiba_add_quick_edit($column_name, $post_type) {
if ($column_name != 'widget_set') return;
?>
<fieldset class="inline-edit-col-left">
<div class="inline-edit-col">
    <span class="title">Widget Set</span>
    <input type="hidden" name="shiba_widget_set_noncename" id="shiba_widget_set_noncename" value="" />
    <?php // Get all widget sets
        $widget_sets = get_posts( array( 'post_type' => 'widget_set',
                        'numberposts' => -1,
                        'post_status' => 'publish') );
    ?>
    <select name="post_widget_set" id='post_widget_set'>
        <option class="widget-option" value="0">None</option>
        <?php 
        foreach ($widget_sets as $widget_set) {
            echo "<option class="widget-option" value="{$widget_set->ID}">{$widget_set->post_title}</option>\n";
        }
            ?>
    </select>
    </div>
    </fieldset>
    <?php
}

Line 5 – Only render our Quick Edit extension on the relevant screen.
Lines 7 to 25 – Render our custom drop-down menu for selecting widget sets.

Leave a Comment