Support » How-To and Troubleshooting » Expiration date added to Quick Edit screen?

Expiration date added to Quick Edit screen?

  • I need to add the same expiration date to most of my posts and I have to Edit, scroll down, enter the expiration date on every one. It would be nice to have the expiration date field added to the Quick Edit screen, then I could apply a bulk action to apply the same date to all of them at once, which would save me a ton! of time. Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator keesiemeijer


    How do you set the expiration date on the normal Post edit screen? Do you enter the date in a custom field?

    I need to add the same expiration date to most of my posts and I have to Edit, scroll down,


    Moderator keesiemeijer


    Not sure where you can set an expiration date. Do you use a plugin?

    Yes, I use Atropos.

    I have the same problem.
    Have a custom field on posts (not a custom type poste just a custom date from a datepicker, that I can easily retrieve in my templates with :
    get_post_meta($post->ID, '_datepicker', true)
    I can edit it in post admin, it saves ok, but I would like to be able to bulk edit it. I can’t find a working exemple with a date, just arrays etc and I’m not good enough to create it… :/
    Because of the problem with bulk edit mode, I found a code which seems to work and even sort column which is really usefull but it gives me a weird result instead of the date in bulk mode (ex : 8ded34858d instead of 2012-09-22). Maybe because it was created for an input?! Could someone help me to fix this code and adapt it for my meta date field “_datepicker”, text field “event_lieu” and dopdown field “type_de_event”…?

    function datepicker_column_orderby( $vars ) {
    if ( isset( $vars['orderby'] ) && 'datepicker' == $vars['orderby'] ) {
    $vars = array_merge( $vars, array(
    'meta_key' => '_datepicker',
    'orderby' => 'meta_value_num'
    ) );
    return $vars;
    add_filter( 'request', 'datepicker_column_orderby' );	
    function datepicker_column_register( $columns ) {
    $columns['datepicker'] = __( 'datepicker', 'my-plugin' );
    return $columns;
    add_filter( 'manage_edit-post_columns', 'datepicker_column_register' );
    function datepicker_column_display( $column_name, $post_id ) {
    if ( 'datepicker' != $column_name )
    $price = get_post_meta($post_id, "_datepicker", true);
    if ( !$price ) {
    $price = '' ;
    {$price = date('Y-m-d', strtotime(get_post_meta($post_id, "_datepicker", true)));
    echo $price;
    add_action( 'manage_posts_custom_column', 'datepicker_column_display', 10, 2 );
    function datepicker_register_sortable( $columns ) {
    $columns['datepicker'] = 'datepicker';
    return $columns;
    add_filter( 'manage_edit-post_sortable_columns', 'datepicker_register_sortable' );
    // Add to our admin_init function
    add_action('quick_edit_custom_box', 'datepicker_quick_edit', 10, 2);
    function datepicker_quick_edit($column_name, $post_type) {
    if ($column_name != 'datepicker') return;
    <fieldset class="inline-edit-col-left">
    <div class="inline-edit-col">
    <span class="title">Date de l'Event</span>
    <input type="text" name="datepicker_noncename" id="datepicker_noncename" value="" />
    add_action('save_post', 'datepicker_quick_edit_data');
    function datepicker_quick_edit_data($post_id) {
    if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
    return $post_id;
    // Check permissions
    if ( 'page' == $_POST['post_type'] ) {
    if ( !current_user_can( 'edit_page', $post_id ) )
    return $post_id;
    } else {
    if ( !current_user_can( 'edit_post', $post_id ) )
    return $post_id;
    $post = get_post($post_id);
    if (isset($_POST['_datepicker']) && ($post->post_type != 'revision')) {
    $datepicker_val = esc_attr($_POST['_datepicker']);
    if ($datepicker_val)
    update_post_meta( $post_id, '_datepicker', $mailer_order_val);
    delete_post_meta( $post_id, '_datepicker');
    return $widget_set_id;
    // Add to our admin_init function
    add_action('admin_footer', 'datepicker_quick_edit_javascript');
    function datepicker_quick_edit_javascript() {
    global $current_screen;
    if (($current_screen->id != 'edit-post') || ($current_screen->post_type != 'post')) return; 
    <script type="text/javascript">
    function set_inline_datepicker(datePicker, nonce) {
    // revert Quick Edit menu so that it refreshes properly
    var metaInput = document.getElementById('_datepicker');
    var nonceInput = document.getElementById('datepicker_noncename');
    nonceInput.value = nonce;
    // check option manually
    for (i = 0; i < metaInput.options.length; i++) {
    if (metaInput.options[i].value == datePicker) {
    metaInput.options[i].setAttribute("selected", "selected");
    } else { metaInput.options[i].removeAttribute("selected"); }
    add_filter('post_row_actions', 'datepicker_expand_quick_edit_link', 10, 2);
    function datepicker_expand_quick_edit_link($actions, $post) {
    global $current_screen;
    if (($current_screen->id != 'edit-post') || ($current_screen->post_type != 'post')) return $actions; 
    $nonce = wp_create_nonce( 'datepicker'.$post->ID);
    $datepicker_val = get_post_meta( $post->ID, '_datepicker', TRUE);
    $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="';
    $actions['inline hide-if-no-js'] .= esc_attr( __( 'Edit this item inline' ) ) . '" ';
    $actions['inline hide-if-no-js'] .= " onclick=\"set_inline_datepicker('{$datepicker_val}', '{$nonce}')\">";
    $actions['inline hide-if-no-js'] .= __( 'Quick&nbsp;Edit' );
    $actions['inline hide-if-no-js'] .= '</a>';
    return $actions;


Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Expiration date added to Quick Edit screen?’ is closed to new replies.
Skip to toolbar