Support

Account

Home Forums ACF PRO Reusing Custom Fields in Other Fields

Solving

Reusing Custom Fields in Other Fields

  • Hi,

    I tried searching for this, and I imagine this question has been asked before, but I couldn’t find it.

    Say I have an existing repeater field — is there a way to reuse that field within a flexible content field, without having to recreate it?

    I guess the question could be asked in broader terms: is there a way to reuse existing fields in field types that are comprised of sub-fields?

    Thanks!

  • The answer to this is no, this is not possible. This is due to the way nested fields are set up with using a parent child relationship. Each parent field has a unique ID and the sub fields are associated with this ID.

    I have never tried or tested the following, so I cannot guarantee it will work or if there might be any side effect of doing it that would cause problems. If you created the fields and exported them, then you duplicated the fields that you want to reuses into different layouts, keeping all the same settings and field_ids, it may be possible. But like I said, I’ve never tested this theory.

  • Thanks for you reply, John. I will have to give this a try, though I can already see how this could potentially not tie the original field to the field created via duplication in the layout — if I were to modify the original field, I doubt that modification would carry through to the duplicated field based on your answer.

  • I’m thinking that doing this in the code could make ACF store and retrieve the values from the same place.

    ACF stores the subfields of a flex field in the database as

    $fex_field_name.'_'.$row.'_'.$sub_field_name

    Nothing will keep you from having to duplicate the fields if you want to have the same fields in multiple layouts, either in code or in the editor. The only thing my suggestion might do is alter the way the field data is stored in the database.

    I’ve found that if I want to have lots of layouts that all use common fields that a repeater with a heavy does of conditional logic is a better choice than flexible content fields.

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

You must be logged in to reply to this topic.