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
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.