• Resolved Tunn

    (@iuriem)


    Hi, Greg!

    How can I rename a form field label, let’s say the “Title” label? Sure, I can simply translate it with the Loco Translate plugin as I need, however I will like to use a function for this, if it is possible. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi, yes it is possible to do this using Forms API, the code below will allow you to change the label of the Title field to something else, you can add the code in theme functions.php file

    
    add_filter( "adverts_form_load", "rename_post_title_in_adverts_add" );
    function rename_post_title_in_adverts_add( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "post_title" ) {
            $form["field"][$key]["label"] = "Custom Title";
        }
      }
      return $form;
    }
    
    Thread Starter Tunn

    (@iuriem)

    @gwin

    Greg, thank you very much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Rename a form field label’ is closed to new replies.