• Resolved emanuelemn

    (@emanuelemn)


    I want to order custom fields in admin. It doesn’t work with drag and drop, and I was thinking of creating a code for this.

    Hi, I started a sutom code in the functions.php file.

    But I couldn’t get it to work

    Do you have any idea how to make it work?

    Thank you

    function reordoneaza_acf_group($group_id, $new_order) {
       // Make sure ACF is enabled
        if (!function_exists('acf_update_field_group')) {
            return;
        }
    
    // Get the current fieldgroup
        $group = acf_get_field_group($group_id);
    
      // Checks if the group exists and has fields
        if (!$group || empty($group['fields'])) {
            return;
        }
    
       // Update the order of the fields in the group
        $group['fields'] = $new_order;
    
        // Update the field group with the new order
        acf_update_field_group($group);
    
        return true;
    }
    
    
    $group_id = 'group_6537b665691a9'; // Replace with your ACF field group ID
    $new_order = array(
        'field_6537b66644bc6',
        'field_6537b66d44bc7',
        'field_6537b67144bc8'
    ); 
    // Replace with field keys in desired order
    
    reordoneaza_acf_group($group_id, $new_order);
    
Viewing 1 replies (of 1 total)
  • Plugin Support ACF Support

    (@acfsupport)

    Hi there!

    ACF Support Team here. This forum is generally used by ACF users to help each other out.

    However, we would love to continue investigating and troubleshooting this issue, please can you create a ticket using our ?support form and we can look into it further.

Viewing 1 replies (of 1 total)
  • The topic ‘How can I order the custom field in admin instead of drag and drop’ is closed to new replies.