Support

Account

Home Forums Front-end Issues Show 'prepend' text from number field Reply To: Show 'prepend' text from number field

  • Hi John,
    That was very helpful thanks but I would like to take it a bit further, I have made a field called ‘property_prefix’ in the options panel as a text field and then I want to update the prefix of a custom field called ‘reference’ when editing in my CPT ‘properties’ so I have done this but I can’t seem to get it to update.

    if ( is_admin() || $post_type === 'properties' ) {
    	$post_id = isset( $_GET[ 'post' ] ) ? $_GET[ 'post' ] : - 1;
    	$field = get_field_object('reference', $post_id);
    	$fieldToUpdate = $field['prepend'];
    	$valueToUpdate = get_field('property_prefix','options');
    	
    	// echo "field: " . $fieldToUpdate . "<br />value: " . $valueToUpdate . "<br />post ID: " . $post_id; this shows the correct information
    	
    	update_field( $fieldToUpdate, $valueToUpdate, $post_id );
    	}

    I can do it by jQuery but would rather not to as when the page loads there is a delay before the prefix is shown.

    Any help would be appreciated, thanks