Home › Forums › Front-end Issues › Controlling fields order and labels in acf_form › Reply To: Controlling fields order and labels in acf_form
1) When using the build in WP title and content fields there isn’t any way to alter the order of them. To do this you would have to create content and title fields in ACF and then transfer the content of them to the standard fields on acf/save_post by getting the values from acf and updating the post.
add_action('acf/save_post', 'my_update_post', 20);
function my_update_post($post_id) {
$post = array(
'ID' => $post_id,
'post_content' => get_field('my_alt_content_field', $post_id),
'post_title' => get_field('my_alt_title_field', $post_id)
);
// remove this filter to prevent infinite loop
remove_filter('acf/save_post', 'my_update_post', 20);
// update post
wp_update_post($post);
// re-add filter
add_action('acf/save_post', 'my_update_post', 20);
}
2) Yes, acf/prepare_field can be used to do this, your filter would look something like
add_filter('acf/prepare_field/key=field_123456', 'alter_label_on_field_a');
function alter_label_on_field_a{$field) {
if (is_admin()) {
// no change in admin
return $field;
}
$field['label'] = 'new label for front end form';
return $field;
}
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.