Support

Account

Home Forums ACF PRO From ACF text field to taxonomy

Helping

From ACF text field to taxonomy

  • Hi,
    For a custom post type, I’ve created a text field named “year”. Now, I need to use this field for a function which needs taxonomy. So I created a taxonomy (“years”). Is it possible to migrate ACF text field to taxonomy and populate it in each post? Thanks for any suggestion.
    Best regards.

  • You would have to

    • Query All Posts and loop over them
    • Get the value of the text field for each post
    • See if there is a term that matches the text field
    • If there is no term then add the term
    • add the term to the post

    You would need to create an “init” action that does the above and then once completed remove the action.

    If you have a lot of posts this could time out. In this case you would delete ACF field after performing the update and in your query you would only get posts where the meta key exists. Then you reload the page until it does not timeout and this will mean that all posts have been migrated and you can delete the action.

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

You must be logged in to reply to this topic.