Home Forums General Issues Field's key not globally unique anymore Reply To: Field's key not globally unique anymore

  • Wow amazing ! I had no idea ACF used post_name value.
    In my boilerplate I had this filter :

    // Replace apostrophes with dashes only once when saving a post.
    // By default wordpress remove them.
    function wm_insert_post_data_customize( $data, $postarr ) {
    	$post_id = $postarr['ID'];
    	// do nothing if post is auto-draft (when creating new post)
    	if(in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) )) return $data;
    	// only if new
    	$is_new = get_post_meta($post_id, 'post_is_new', true);
    	if ( $is_new != 'true' ) {
    		$post_title = str_replace("'", "-", $data['post_title']);
    		$data['post_name'] = wp_unique_post_slug( sanitize_title( $post_title, $post_id ), $post_id, $data['post_status'], $data['post_type'], $data['post_parent'] );
    		// set the 'post_is_new' value
    		update_post_meta($post_id, 'post_is_new', 'true');
    	return $data;
    add_filter( 'wp_insert_post_data', 'wm_insert_post_data_customize', 50, 2 );

    So I added a new line after the first if(...) return $data; :
    if($data['post_type'] == 'acf-field-group' or $data['post_type'] == 'acf-field') return $data;
    And now it works like a charm.

    Thank you for the help, cheers !