I’ve been trying to add a field to Quick Edit. Somehow it works: it is displayed and if you enter a value in the input field, the value is saved into a custom field. However, can’t seem to find a way to retrieve the value of the custom field. Here’s what I got so far:
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
}
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
}
Downloaded the Custom Field Template plugin to dissect the code and found that they are redefining portions of the inlineEditPost function, so I thought about doing the same thing. However, they appear to be doing it through an options array where a duplicate is stored.
If you have solved this, could you share what you’re using to retrieve the values for each custom field?