Home › Forums › General Issues › Can't override template in my child theme
Hello to all,
I’ve been stuck on this for 2 days now… Indeed, I want to modify the template file acf-field-functions.php in the includes folder of the plugin by overloading it in my child theme. Unfortunately, after following the documentation Including ACF within a plugin or theme and testing a lot of things, I can’t override the acf_get_field_label function of the template in my child theme, even with the add_action in the functions.php file of my theme.
Can you help me and explain me the procedure to modify the acf_get_field_label function of the acf-field-functions.php template in my child theme ?
Thanks in advance.

You cannot override ACF functions.
ACF provides a filter for altering the results of this function, you can see it in that function.
$label = apply_filters( 'acf/get_field_label', $label, $field, $context );
Hello John,
Can you tell me how to change the required HTML <span class="acf-required">*</span> or remove it with this filter ?
And can you tell me how I can modify the labels of the error messages when submitting the form without being able to overload a function ?
Thank you very much for your reply.

You can’t remove <span class="acf-required">*</span>. You need ot make the field not required or use custom CSS to hide it.
Changing error messages requires using JS. see https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/ and https://www.advancedcustomfields.com/resources/javascript-api/ I don’t have any examples. You might find something here or on similar topics https://support.advancedcustomfields.com/forums/topic/acf_form-with-custom-validation-message/
You must be logged in to reply to this topic.
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.