Support

Account

Home Forums General Issues add custom id to acf field

Solved

add custom id to acf field

  • hi i tried this function to add it :

    function my_load_field($field)
    {
    	$regex .= ' custom_acf_class_' . $field['name'];
    	// add to class
    	if (!preg_match('~' . $regex . '~', $field['wrapper']['class'])) {
    		$field['wrapper']['class'] .= ' custom_acf_class_' . $field['name'];
    
    		// return
    		
        }
        if(!$field['wrapper']['id']){
            $field['wrapper']['id'] = strval(rand(10000000000,100000000000)). '_' . $field['name'];
        }
        return $field;
    }

    problem is the id value is the same for all field. rand value seems to be stocked or hooks called once…

    how can i do ?

  • i finally found the problem, in acf clone filed choose the “group” in display format option

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

You must be logged in to reply to this topic.