Home Forums ACF PRO Update Field via Quick Edit


Update Field via Quick Edit

  • Hi,

    I have a custom post type that has an expiry date custom field. This field is automatically populated by the published date of the post. When I update the published date on the post edit screen, the date updates fine.

    But when updating the published date within the Quick Edit screen, the expiry date does not update.

     * Update the expiry date custom field in the backend.
    add_filter('save_post', 'add_expiry_date');
    function add_expiry_date($post_id) {
    	$published_date = get_the_date( 'm/d/Y', get_the_ID() );
    	$expiry_date    = date( 'm/d/Y', strtotime( '+2 days', strtotime($published_date) ) );
    	update_field( 'listing_expiry_date', $expiry_date, $post_id );

    Any help would be most appreciative.


  • The save_post action should fire during quick edit as well as when editing the post.

    The only issue I can see with the above code is the date format and I don’t see how this can work when editing the post at all.

    The date format for update_field should always by “Ymd”.

    Another issue could be that the field does not already have a value. In this case you must use the field key and not the field name.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.