WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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' ) ); ?>
share|improve this answer
Thanks, that worked. The Codex doesn't give any clue what the possible options are, and it's not in the function's phpdoc either. I looked through template.php and it looks like 'label_for' is the only argument. I'll update the Codex. – Ian Dunn Sep 1 '11 at 14:47
@Ian you should check core for do_settings_fields, but unfortunately there is no full list of $args – Mamaduka Sep 1 '11 at 19:58
Yeah, I did. label_for is the only one mentioned in do_settings_fields(). I updated the Codex with the info. – Ian Dunn Sep 1 '11 at 20:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.