How could I add a description to $wp_customize->add_control
? I’ve found I really need to include a short description on some of the controls but it doesn’t look like it’s possible.
I noticed you can add a description to $wp_customize->add_section
but that’s only a tooltip.
This is ideally what I’d like to do, but unsure on how to output it and if this is possible:
$wp_customize->add_control( 'theme_options[some_option_name]', array(
'label' => 'This Is Some Option',
'section' => 'theme_name_section',
'type' => 'text',
'description' => 'Wish this existed', // this isn't possible
));
Here is one way to do it by extending the control you want to use.
Below is an example where we extend the text control and add an extra description like the one seen here on the screenshot:
It is helpful to check out the source of the
WP_Customize_Control
class:https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-customize-control.php
Hope this helps.
For anyone who comes across this after WordPress 4.0 is released, custom controls are no longer necessary. This functionality is baked right into WordPress: https://core.trac.wordpress.org/ticket/27981.
The description argument adds a description under the control. If you want to add something above the control title, like an extra header or something, you can use the
customize_render_control_{id}
action. For example, if you wanted to add a button above a control with the idhi_shawn
you could do this: