Home › Forums › General Issues › Programmatic duplication › Reply To: Programmatic duplication
I’m not 100% certain, didn’t dig that far, but I think the function you’re calling acf_duplicate_fields();
is an internal ACF function that’s used to either duplicate a field group or to duplicated fields inside a field group and not to duplicate the meta values associated with a post.
If you need to manually duplicate all of the post meta attached to a post then use.
$meta = get_post_meta($post_id);
when used without a meta_key
this returns an array of all meta values attached to a post. For more information see the codex here https://developer.wordpress.org/reference/functions/get_post_meta/
Then you’d need to loop through this array and use add_post_meta()
for each key in the array to add it to the new post. As far as I know there isn’t a function to add all the meta values in one go.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.