Adding labels to Setting titles with API

If I add a setting using add_settings_field(), it doesn’t create a <label> around the title so that it can be clicked to focus on the field. Some of the core settings do this, but they just add it in the raw HTML rather than using the settings API. Is there any way to add labels with the settings API?

Related posts

Leave a Reply

1 comment

  1. You need to pass last parameter $args, if you want add_settings_field to output <label> use `label_for’ argument, see code snippet below

    <?php add_settings_field( 'my-id', 'Test Filed', 'mamaduka_test_field', 'general', 'my-section', array( 'label_for' => 'my-test-field' ) ); ?>