1

I'm working on a site update for a client. The current version of their site stores a lot of information within custom post meta fields, added as plain text boxes using Advanced Custom Fields. We think this information would serve the site better if it existed as a taxonomy, so we'd like to move all this information into a custom taxonomy.

This is a film site and one example is that the film's director is stored as a plain text post meta field. If it were part of a Director taxonomy instead, we could easily look at all films tagged with that Director.

So my question - is there is an easy way to move or copy information in a post meta field to a custom taxonomy? My plan at the moment is to look at a plugin for copying info between taxonomies and seeing if I can modify that. But if anyone knows of another solution, I'd be grateful!

Many thanks.

1
  • 1
    There's no easy way. Your best bet would be to write a WP-CLI script to loop through the posts and assign the new terms to your custom taxonomy as you go.
    – vancoder
    Aug 13, 2020 at 21:02

1 Answer 1

0

You will need to write some code for this I think. Start creating the new taxonomies and the query the right custom field to get the list of values. Use wp_insert_term() to add the new term. Then use wp_set_post_terms() to assign the terms to each post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.