19

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?

5

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.

| improve this answer | |
2

Note that we are wrapping our post meta in a div with an id of “release_date-” plus the post id. This will come in handy when we are populating our “Quick Edit” row. Full Detail here

add_action( 'manage_posts_custom_column', 'rachel_carden_populating_my_posts_columns', 10, 2 );
function rachel_carden_populating_my_posts_columns( $column_name, $post_id ) {
   switch( $column_name ) {
      case 'release_date':
         echo '<div id="release_date-' . $post_id . '">' . get_post_meta( $post_id, 'release_date', true ) . '</div>';
         break;
   }
}
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.