Support

Account

Home Forums ACF PRO Copy field values between posts

Solved

Copy field values between posts

  • Hi everyone,
    I’m building a website that will have multiple custom fields per page and in this particular instance, my client ask for possibility to copy values from one post to another. So basically they will prepare product characteristics for single product and then would want to copy this over to more products as a starter template so that they only change what is different.
    Not sure if I make myself clear but basically I’d like to open a post, copy one or multiple field values (text fields, repeaters, groups etc) to another post.
    Do you know of any solution for such case?

    Many thanks
    Martin

  • For this I use https://wordpress.org/plugins/duplicate-post/ and there are other plugins that will do it. Copy any post and start from there.

  • Yeah, I’m aware of this but never used it for other than “duplicating” posts. Do you have any idea whether it’s capable of duplicating values to existing posts?
    Perhaps to better describe what I’m after. The products are custom branded electronics. So say I have product A which at current time has various field groups such as:

    • price
    • discounts
    • technical specification

    Now, when the season comes, they want to change price / discounts field groups (Price for example is a repeater field with columns: Price, Name, Tax, Valid from, Valid to). When they do, they then want to copy these settings to all other products within category and to through each of them and just amend the Price (or discount).
    I’ve been thinking about doing global Price/discount settings but that won’t do as basically each product has some differences. The problem is that those differences are very small. So I can’t build a template and yet it’s tedious work to set it up for every product from scratch.

  • I misunderstood it seems.

    There isn’t any way to copy values from an existing post to another existing post.

    Any solution would have to be custom built based on the needs of the client and what is being copied.

    As an example you could add a true false field or some other type of field that allows setting what to copy or where to copy it to. The you could create an acf/save_post field that checks these fields that then does the copying.

    The main issue you’ll run into is scalability. Copying date across posts would take time and likely time out if there was a lot of copying to do.

    A better solution would be to have a options page, or if the values are based on categories to have custom fields on the categories rather than individual posts. Any time identical values will apply to more than one post it is best to store them somewhere other than for each post.

  • Many thanks for your answer. I was afraid there isn’t any easy way to do this. I’ll have to figure something out. Your idea hooking on acf/save_post is great. I’ll try to build it around this.

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

You must be logged in to reply to this topic.