The customize_partial_render WordPress PHP filter allows you to modify the rendering of a partial value in the Customizer.
Usage
add_filter( 'customize_partial_render', 'your_custom_function', 10, 3 ); function your_custom_function( $rendered, $partial, $container_context ) { // Your custom code here return $rendered; }
Parameters
$rendered
(string|array|false): The partial value. Default false.$partial
(WP_Customize_Partial): WP_Customize_Setting instance.$container_context
(array): Array of context data associated with the target container.
More information
See WordPress Developer Resources: customize_partial_render
Examples
Change site title
Modify the site title in the Customizer.
add_filter( 'customize_partial_render', 'change_site_title', 10, 3 ); function change_site_title( $rendered, $partial, $container_context ) { if ( 'blogname' === $partial->id ) { $rendered = '<h1 class="site-title">' . get_bloginfo( 'name' ) . '</h1>'; } return $rendered; }
Add custom text to site description
Add custom text to the site description in the Customizer.
add_filter( 'customize_partial_render', 'add_custom_text_to_description', 10, 3 ); function add_custom_text_to_description( $rendered, $partial, $container_context ) { if ( 'blogdescription' === $partial->id ) { $rendered .= ' - Custom Text'; } return $rendered; }
Modify navigation menu
Modify the navigation menu in the Customizer.
add_filter( 'customize_partial_render', 'modify_navigation_menu', 10, 3 ); function modify_navigation_menu( $rendered, $partial, $container_context ) { if ( 'nav_menu' === $partial->type ) { $rendered = str_replace( 'menu-item', 'custom-menu-item', $rendered ); } return $rendered; }
Add custom CSS class to widget
Add a custom CSS class to a widget in the Customizer.
add_filter( 'customize_partial_render', 'add_custom_css_class_to_widget', 10, 3 ); function add_custom_css_class_to_widget( $rendered, $partial, $container_context ) { if ( 'widget' === $partial->type ) { $rendered = str_replace( 'class="widget', 'class="custom-widget', $rendered ); } return $rendered; }
Modify footer text
Modify the footer text in the Customizer.
add_filter( 'customize_partial_render', 'modify_footer_text', 10, 3 ); function modify_footer_text( $rendered, $partial, $container_context ) { if ( 'footer_text' === $partial->id ) { $rendered = str_replace( 'Powered by WordPress', 'Custom Footer Text', $rendered ); } return $rendered; }