0

Using add_settings_field(); i am able to add my custom setting:

add_settings_field('AUTOPLAY', 'Auto Play', 'printAutoPlayCheckbox', 'my_settings');


function printAutoPlayCheckbox()
{
   $id = 'AUTOPLAY';
   $name = 'my_settings' . "[$id]";
   $options = get_option('my_settings');
   echo '<input type="checkbox" id="' . $id . '" name="' . $name . '" ' . checked(1, isset($options[$id]), false) . '" />';
}

enter image description here

Now i want to add a short description of this setting, something like that:

enter image description here

How can i do that? I couldn't find it in the WordPress docs.

3
  • There's no code in your question, can you edit your question to include it? This is not something I've seen in standard WordPress APIs, and the styling does not appear to be normal either
    – Tom J Nowell
    Apr 27, 2021 at 11:23
  • Added some code
    – TheDoctor
    Apr 27, 2021 at 11:46
  • I had to edit the code to prevent a PHP Fatal syntax error. I did se that there are strings with embedded PHP variables, and no escaping functions are being used, which are both security concerns
    – Tom J Nowell
    Apr 27, 2021 at 11:57

1 Answer 1

1

I've not seen this type of title settings layout in the admin pages, so it seems you're parting away from it.

Otherwise note that the title field of add_settings_field() is unescaped, so in theory one could add some HTML code for new title layout.

Usually the description is added to the input field.

1
  • Ok, i'll try it
    – TheDoctor
    Apr 27, 2021 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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