The customize_render_panel WordPress PHP action fires before rendering a Customizer panel.
Usage
add_action('customize_render_panel', 'your_custom_function');
function your_custom_function($panel) {
// your custom code here
}
Parameters
- $panel (WP_Customize_Panel) – The instance of the WP_Customize_Panel class.
More information
See WordPress Developer Resources: customize_render_panel
Examples
Change Panel Title
Modify the title of a Customizer panel before rendering.
add_action('customize_render_panel', 'change_panel_title');
function change_panel_title($panel) {
if ($panel->id == 'your_panel_id') {
$panel->title = 'New Panel Title';
}
}
Add HTML Content Before Panel
Add custom HTML content before a specific Customizer panel.
add_action('customize_render_panel', 'add_content_before_panel');
function add_content_before_panel($panel) {
if ($panel->id == 'your_panel_id') {
echo '<div class="custom-content">Your custom HTML content here</div>';
}
}
Change Panel Description
Update the description of a Customizer panel before rendering.
add_action('customize_render_panel', 'change_panel_description');
function change_panel_description($panel) {
if ($panel->id == 'your_panel_id') {
$panel->description = 'New panel description.';
}
}
Add CSS Class to Panel
Add a custom CSS class to a specific Customizer panel.
add_action('customize_render_panel', 'add_css_class_to_panel');
function add_css_class_to_panel($panel) {
if ($panel->id == 'your_panel_id') {
$panel->container_classes[] = 'your-custom-class';
}
}
Remove Panel Based on User Role
Remove a Customizer panel for non-admin users.
add_action('customize_render_panel', 'remove_panel_for_non_admin');
function remove_panel_for_non_admin($panel) {
if (!current_user_can('manage_options') && $panel->id == 'your_panel_id') {
$panel->active = false;
}
}