Support

Account

Home Forums General Issues PHP Notice when seeing post object after programmatically assiging it Reply To: PHP Notice when seeing post object after programmatically assiging it

  • I think you are trying to pass an array in the update field function and you haven’t defined a field. I think you need to pass a number to the post object. You may want to add another variable to get the page ID.

    Whatever $nombre_cargo is, you need to use the field name or field key as the first parameter of the update field function. For example: ‘nombre_cargo’ or ‘field_123456890’

    Try this, but replace the name of the field first.

    $per_obj = get_page_by_title( $resp, OBJECT, 'persona' );
    				
    if (!is_null($per_obj)) {
    	
            $page = per_obj->ID;
    } 						
    update_field( 'cargo_number', $page, $post_id );