WordPress.org

Ready to get started?Download WordPress

Forums

Update Function for Post_Date via a Filter or Action ? (4 posts)

  1. BastianG
    Member
    Posted 1 year ago #

    Hi,

    I want to improve my functions.php and set a post_date according to an exif date of a specific posted picture. To get the exif date and store in a string is no problem even the conversion to a date is no problem, the challenge I am facing is whether there is a nice function which can be used in a filter/action/??? Otherwise my last chance would be to update the date via an update directly on the DB side, which I try to avoid.

    Thanks a lot - Bastian

  2. bcworkz
    Member
    Posted 1 year ago #

    Hook the filter 'wp_insert_post_data'. Your function will be passed an array which in part has the date fields. You will want to change the array values for the keys 'post_date' and 'post_date_gmt'. Then return the altered array.

  3. BastianG
    Member
    Posted 1 year ago #

    Thanks a lot !!! Exactly what I needed to get it done :-)

  4. Driftless
    Member
    Posted 1 year ago #

    Shameless plugin plug

    Along the same lines - I just released a plugin that does this (updates post dates to attached photo's EXIF date) in bulk for the post type of your choosing: EXIFize My Dates

Topic Closed

This topic has been closed to new replies.

About this Topic