This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
customize_partial_render_partial-id filter
The dynamic portion of the hook name, $partial->ID refers to the partial ID.
To use customize_partial_render_partial-id filter, first you have to register it using add_filter. You can write this code into functions.php of your activated theme or in a custom WordPress Plugin.
We at WePlugins, always prefer to create a custom WordPress Plugin while using hooks so nothing breaks when you update your WordPress Theme in the future.
In the below live example, we have defined a function modify_customize_partial_render_partial-id_defaults which takes 3 parameters and we registered using add_filter. The first parameter customize_partial_render_partial-id is name of the hook, The second parameter modify_customize_partial_render_partial-id_defaults is name of the function which need to be called, third parameter is the priority of calling the hook if same hook is used multiple times and the last parameter is the number of arguments (if any) to be passed in the registered function.
Sometime, you have to remove a registered hook so you can use remove_filter to remove customize_partial_render_partial-id filter.
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.
Below are the 3 parameters are required to use this hook.
Live Example
apply_filters( "customize_partial_render_{$partial->id}", string|array|false $rendered, WP_Customize_Partial $partial, array $container_context )
Below is an example how you can use this hook.
Example 1: Basic Usage
In this example, we modify the rendered partial value without any conditions.
function weplugins_modify_customize_partial_render_partial_id($rendered, $partial, $container_context) { // Update the $rendered variable according to your website requirements and return this variable. return $rendered; } // add the filter add_filter( "customize_partial_render_partial-id", "weplugins_modify_customize_partial_render_partial_id", 10, 3 );
Example 2: Conditional Modification
Here, we modify the rendered partial value based on certain conditions.
function weplugins_modify_customize_partial_render_partial_id_conditional($rendered, $partial, $container_context) { if ($partial->id == 'specific_partial_id') { $rendered = 'New Value for specific_partial_id'; } return $rendered; } // add the filter add_filter( "customize_partial_render_partial-id", "weplugins_modify_customize_partial_render_partial_id_conditional", 10, 3 );
Example 3: Removing the Filter
To remove a hook callback, use the example below.
remove_filter( "customize_partial_render_partial-id", "weplugins_modify_customize_partial_render_partial_id", 10, 3 );
Please make sure to provide the same callback function name, priority and number of arguments while removing the hook callback.
Contact Us
If you need any customization or have trouble using this hook, please contact us.
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.