Home Forums Bug Reports Field Group Ordering Incorrect on JSON Sync


Field Group Ordering Incorrect on JSON Sync

  • When importing the field groups from JSON, such as on a sync, the first subfield in the JSON array does not maintain its first position within its parent in the imported fields. It is moved to the end of the parent field.

    A recent change in acf_import_field_group seems to be the culprit with this addition

    // Only add menu order if doesn't already exist.
    // Allows Flexible Content field to set custom order.
    if( empty($field['menu_order']) ) {
        $field['menu_order'] = ($count[ $field['parent'] ] - 1);

    When preparing the fields for sync, the incorrect menu orders are set to their position in the subfield array, which is zero. The call to empty returns true for the first item, but false for all remaining items, which moves the item to the end of its siblings. I believe this should be changed to a check if the key exists rather than empty.

    I can submit simplified reproduction steps if necessary. Our temporary work-around is to remove the conditional check for emptiness and set the menu order based on parents child count, as it was before the change.

    Thanks for looking into this!

  • hello,
    we encounter the same issue hereโ€ฆ it’s quite a mess with lots of flexible fields!
    what is your workaround exactly?

    if( empty($field['menu_order']) && $field['menu_order'] !== 0) {
        $field['menu_order'] = ($count[ $field['parent'] ] - 1);

    Went for the pragmatic fix… ๐Ÿ˜‰ In the short term, we’re just being careful not to overwrite it on version updates, and wait patiently for the fix.

  • thanks!!

  • Experiencing the same thing. When syncing fields to the database from the acf-json folder, the first field (usually an Accordion field type) in each of my flexible content layouts ends up at the bottom of the list.

  • the dev is aware of this issue and a fix will be in the next update. I posted a temporary work-a-round here.

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

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.