Support

Account

Home Forums Backend Issues (wp-admin) Replacing custom post type post title with an acf? Reply To: Replacing custom post type post title with an acf?

  • I’ve got this working just as desired with regular text fields, but I’m having trouble doing it with a repeater. I’m using a repeater because the columns make the layout a lot cleaner, but there’s only a single row. The repeater has 3 sub fields, all text. Here’s my latest attempt:

    
    function sk_acf_update_pocket_postdata( $value, $post_id, $field ) {
    	global $_POST;
    	
    	$pocket_name_fields = $value[0];
      
    	$head_brand = $pocket_name_fields['head_brand'];
    	$head_name = $pocket_name_fields['head_name'];
    	$pocket_type = $pocket_name_fields['pocket_type'];
      
    	$pocket_title = $head_brand . ' ' . $$head_name . ' ' . $pocket_type;
    	$pocket_slug = sanitize_title( $pocket_title );
      
      $pocket_postdata = array(
        'ID'          => $post_id,
        'post_title'  => $pocket_title,
    	  'post_name'   => $pocket_slug
      );
      
      wp_update_post( $pocket_postdata );
    	
    	return $value;
    	
    }
    
    add_filter('acf/update_value/key=field_53f7a5039c2a8', 'sk_acf_update_pocket_postdata', 10, 3);
    

    The field key I’m using is for the repeater. I was using a field key for one of the sub fields, and was able to pull that value in successfully, but I wasn’t able to pull in the other two values using get_the_field_object.

    Any help would be greatly appreciated.