Support

Account

Home Forums General Issues Labels on Title and Content

Solved

Labels on Title and Content

  • Hi,

    I’m using acf_form to display a form on the frontend, but it seems impossible to override the default labels for Title and Content for a single post type.

    I looked at prepare_field filter, but it’s only possible to update based on key and name (which also seems to be identical). Also field doesn’t contain the name of the post type.

    Am I missing something here? Or is this a limitation with acf? Would it make sense to raise a feature request to include the field_group in the $field?

    Or is there some way to find out which new_post -> post_type this belongs to?

    array(23) {
      ["ID"]=>
      int(0)
      ["key"]=>
      string(11) "_post_title"
      ["label"]=>
      string(5) "Title"
      ["name"]=>
      string(16) "acf[_post_title]"
      ["prefix"]=>
      string(3) "acf"
      ["type"]=>
      string(4) "text"
      ["value"]=>
      string(0) ""
      ["menu_order"]=>
      int(0)
      ["instructions"]=>
      string(0) ""
      ["required"]=>
      bool(true)
      ["id"]=>
      string(15) "acf-_post_title"
      ["class"]=>
      string(0) ""
      ["conditional_logic"]=>
      bool(false)
      ["parent"]=>
      string(0) ""
      ["wrapper"]=>
      array(3) {
        ["width"]=>
        string(0) ""
        ["class"]=>
        string(0) ""
        ["id"]=>
        string(0) ""
      }
      ["_name"]=>
      string(11) "_post_title"
      ["_valid"]=>
      int(1)
      ["default_value"]=>
      string(0) ""
      ["maxlength"]=>
      string(0) ""
      ["placeholder"]=>
      string(0) ""
      ["prepend"]=>
      string(0) ""
      ["append"]=>
      string(0) ""
      ["_prepare"]=>
      bool(true)
    }
  • There isn’t a way to alter these titles. Instead you would need to use a custom ACF field and then use the values of these to update the title and content. There is code on this page for an example of using an ACF field for title and content would work in a similar way https://support.advancedcustomfields.com/forums/topic/using-a-field-to-define-a-new-post-title-with-acf_form/

  • i got it, thank you for the explanation.

  • This snippet will do it inside an acf_form().

    function my_acf_prepare_field( $field ) { 
    	
    	if ( is_page('add-meme') ) { 
    	
    		$field['label'] = "Keywords"; 
    		$field['instructions'] = "Enter keywords for this Meme"; 
    	}
    	
    	if ( $field ) { return $field; } else { exit; } 
    
    } 
    add_filter('acf/prepare_field/name=_post_title', 'my_acf_prepare_field');
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Labels on Title and Content’ is closed to new replies.