Advanced Custom Fields easily allows you to create the forms in the front end. If you add:

'post_title'      => true,
'post_content'    => true,

in acf_register_form() or acf_form(), the form gives you the fields for Post Title and Post Content with the default labels “Title” and “Content”. In this article, we’re modifying those titles & description

Modify the Title & Content fields

However, sometimes you’d want to change the default field label & description. Here’s how to do this:

/**
 * Modify the content field label.
 *
 * @param array $field The content field data.
 *
 * @since 1.0.0
 */
function sa_post_content_label( $field ) {

	$field['label'] = esc_html__( 'Description', 'text-domain' );
	return $field;
}
add_filter( 'acf/load_field/name=_post_content', 'sa_post_content_label' );

/**
 * Modify the title field description.
 *
 * @param array $field The content field data.
 *
 * @since 1.0.0
 */
function sa_post_content_label( $field ) {

	$field['instructions'] = esc_html__( 'Please specify the title of the post.', 'text-domain' );
	return $field;
}
add_filter( 'acf/load_field/name=_post_title', 'sa_post_content_title' );

In the codes above:

  1. It modifies the label of the Post Content field to “Description”.
  2. It adds the description of the Post Title field to “Please specify the title of the post.”

Similarly, the same hook filter hook acf/load_field/name= can be used to modify the title, description, field name etc. of any field you’ve created with Advanced Custom Fields.

For example: if the field name is url the hook should be acf/load_field_name=url.

Any questions? 🙂

ACF – modify the Title & Content fields
Tagged on:

Sanjeev Aryal

Don't bury your thoughts, put your vision into reality ~ Bob Marley.

Leave a Reply

Your email address will not be published. Required fields are marked *

× WhatsApp