Using WordPress ‘customize_render_control_{$this->id}’ PHP action

The customize_render_control_{$this->id} WordPress PHP action fires just before a specific Customizer control is rendered. The dynamic portion of the hook name, $this->id, refers to the control ID.


add_action('customize_render_control_your_control_id', 'your_function_name');

function your_function_name($control) {
  // your custom code here


  • $control (WP_Customize_Control) – The WP_Customize_Control instance.

More information

See WordPress Developer Resources: customize_render_control_{$this->id}


Modify control layout

Customize the layout of a control with ID my_custom_control.

add_action('customize_render_control_my_custom_control', 'modify_control_layout');

function modify_control_layout($control) {
  echo '<div class="custom-control-layout">';
  echo '</div>';

Add a custom CSS class

Add a custom CSS class to a control with ID my_text_control.

add_action('customize_render_control_my_text_control', 'add_custom_css_class');

function add_custom_css_class($control) {
  echo '<div class="custom-css-class">';
  echo '</div>';

Add a custom attribute

Add a custom data attribute to a control with ID my_color_control.

add_action('customize_render_control_my_color_control', 'add_custom_attribute');

function add_custom_attribute($control) {
  echo '<div data-custom-attribute="example">';
  echo '</div>';

Wrap control in a custom container

Wrap a control with ID my_radio_control in a custom container element.

add_action('customize_render_control_my_radio_control', 'wrap_control_custom_container');

function wrap_control_custom_container($control) {
  echo '<div class="custom-container">';
  echo '</div>';

Add a custom message

Add a custom message above a control with ID my_select_control.

add_action('customize_render_control_my_select_control', 'add_custom_message');

function add_custom_message($control) {
  echo '<p class="custom-message">Please select an option:</p>';