Add a field to Quick Edit
-
Hi there, I’ve been trying to add a field to Quick Edit mode for posts but reached a dead end. The extra field is displayed using:
add_action('quick_edit_custom_box', 'ilc_quickedit_show', 10, 2); function ilc_quickedit_show( $col, $type ) { if( $type != 'event' ) return; ?> <fieldset class="inline-edit-col-left"> <div class="inline-edit-col"> <div class="inline-edit-group"> <label for="eventdate" style="font: italic 12px Georgia, serif;">Event Date</label> <span class="input-text-wrap"> <input type="text" name="eventdate" id="eventdate" size="10" value=""> </span> </div> </div> </fieldset> <?php }
and even entered values are saved using:
add_action('save_post','ilc_quickedit_save',10,3); function ilc_quickedit_save($post_id, $post) { if( $post->post_type != 'event' ) return; update_post_meta($post_id, 'Event Date', $_POST['eventdate']); }
As you surely noticed, this is for a custom post type ‘event’. However, I can’t retrieve the values and populate the fields. AFAIK, this involves inline-edit-post.js but I can’t find any way to use inlineEditPost to retrieve the custom field value. Even the post id is available in the JavaScript scope
add_action('admin_head-edit.php', 'ilc_quickedit_get'); function ilc_quickedit_get() { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('a.editinline').live('click', function() { var id = inlineEditPost.getId(this); alert("Post id: " + id); }); }); </script> <?php }
But, no luck for retrieving the values.
- The topic ‘Add a field to Quick Edit’ is closed to new replies.