Support

Account

Home Forums ACF PRO Updating fields duplicates and splits field group

Solved

Updating fields duplicates and splits field group

  • When updating fields in a singe field group (connected to one custom post type) the updated field gets deleted from the field group and a new field group with the same name is created which now holds that updated field.
    As a result, the fields are no longer shown on the editor for that custom post type.

    This image shows visualy what happened. I first had one field group “Agency fields” which contained 6 fields. After updating on of the fields, that field got moved to the field group with the same name that now sits above the old one.

  • Did a fresh WordPress install, restored database and fresh installed ACF Pro. This issue still remains. Will now try with a fresh install and import of the custom post types

  • Found it. I was using this code in my functions.php:

    		$showID = $wpdb->get_var( $wpdb->prepare( "
    			SELECT ID 
    			FROM $wpdb->posts 
    			WHERE post_name = %s 
    			AND post_type= %s", 'show', 'page' ) );
    			
    		if ( !$showID ) {
    			$showID = wp_insert_post( array(
    				'post_name' => 'show',
    				'post_title' => 'Show',
    				'post_type' => 'page',
    				'post_status' => 'publish'
    				));
    		}
    		wp_update_post( array(
    			'ID'           => $showID,
    			'post_status' => 'private'
    		) );
    

    Turns out the wp_update_post with just the ID and post_status makes this issue alive. Even though it has the correct ID to the page.

  • Hi @woedend

    Thanks for posting the solution!

    Cheers
    E

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

You must be logged in to reply to this topic.