Support

Account

Home Forums ACF PRO Front End Form Title Label

Solved

Front End Form Title Label

  • I am using this code for a front end form.

    <?php acf_form(array(
    ‘post_title’ => true,
    )); ?>

    Can I control the label and the instruction for this field?

    Thanks

  • Hi @frankster1234

    I believe you can do it like this:

    function my_acf_prepare_field( $field ) {
    	
        $field['label'] = "Changed Label";
        $field['instructions'] = "Changed Instruction";
    
        return $field;
        
    }
    add_filter('acf/prepare_field/name=_post_title', 'my_acf_prepare_field');

    To learn more about this hook, please take a look at this page: https://www.advancedcustomfields.com/resources/acfprepare_field/.

    Hope this helps 🙂

  • Thanks again for the great support!

  • Hi James — I just implemented this and it works. However, it changes the name of my Title field on all my front-end forms. I’m trying to figure out how I might apply this to just one form. Any suggestions?

  • Okay, a full night’s sleep allowed me to figure out the obvious solution:) I just used a little logic to check the page template. Although I did have to make sure to exit out if there was no change so the “Title” label showed up on other forms as usual.

     function my_acf_prepare_field( $field ) {
    	
        if ( is_page_template('my-page-template.php') ) {
           $field['label'] = "Changed Label";
           $field['instructions'] = "Changed Instruction";    
        }
        
        if ( $field ) {
            return $field;   
        } else {
            exit;
        }
    }
    add_filter('acf/prepare_field/name=_post_title', 'my_acf_prepare_field');
    
  • Has anyone a idea how to check the post type when using prepare field?
    My form is generated in a shortcode, so using the global $post is not a option.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Front End Form Title Label’ is closed to new replies.