Home Forums Backend Issues (wp-admin) Access field data inside 'wp_insert_post_data' filter?


Access field data inside 'wp_insert_post_data' filter?

    • denny

    • September 11, 2013 at 6:15 am

    I’m creating a database of addresses using the location addon inside a custom post type. The post title is not relevant to this custom post type, so it has been disabled. I would, however, like to be able to show the most recent location in the various areas that WP would normally show a post title without having to re-code portions of the admin (or addons such as the relationship module which defaults to showing post title in results). Thus I’m attempting to push the address from the ACF location addon to the post title on post save/update.

    The code I’ve created so far only works on post update because there are existing values in the DB for ACF fields, but for this reason it’s of course pushing old data to the post title:

    add_filter( 'wp_insert_post_data', 'change_incident_title' );
    function change_incident_title( $post_data )
      if($post_data['post_type'] == 'incident'){
        $location = get_field('address',$post_data['ID']);
        $post_data['post_title'] = $location['address'];
        return $post_data;

    What I’m wondering is if there is any known way to access current ACF data for a post inside the wp_insert_post_data filter before everything is saved to the DB?

    • denny

    • September 11, 2013 at 6:25 am

    Whoops, must’ve thought of better terms to search for this time as I just stumbled across something that will hopefully at least guide me in the right direction:

    • Elliot

    • September 11, 2013 at 2:17 pm

    Hi @denny

    Thanks for searching and for posting the link

    Great work


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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.