Home Forums Backend Issues (wp-admin) Linking ACF Taxonomy to WP Taxonomy on programmatic save/insert


Linking ACF Taxonomy to WP Taxonomy on programmatic save/insert

  • When I programmatically copy a post of one post type to another post type, I am successful in copying multiple ACF Taxonomy values, and can see those values in ACF fields in the new post record. However, the link between the ACF taxonomy and the WP taxonomy isn’t happening until I manually update the new post through the WP interface. I need this link to happen in order to have the values listed in admin columns for that new record and also to display on Front end pages. Is there an ACF function that needs to be called in order for that linking to happen? My function is hooked into the ACF/Save_Post action. Do I also need to call a WP save function/action, or some other ACF function?

  • I don’t think there is a function you can call to do this. When you set the save/load terms options for a taxonomy field ACF calls WP functions with the right info to make this happen.

    When saving the field ACF calls wp_set_object_terms()

    When loading the field ACF calls wp_get_object_terms()

    You can get more information about what ACF is doing by looking at the file for the taxonomy field /advanced-custom-fields-pro/includes/fields/class-acf-field-taxonomy.php.

    I think that in order to do what you want that you’ll need to call these WP functions yourself.

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

You must be logged in to reply to this topic.