When using the filter:
add_filter('widget_display_callback', 'function_name');
function function_name($instance) {
/* Some Code */
return $instance;
}
Is it possible to determine the sidebar name and/or ID the particular widget instance is located within function_name
?
The
widget_display_callback
hook takes 3 arguments as we can see in/wp-includes/widgets.php
: (line 180, WP 3.4.2)$instance = apply_filters('widget_display_callback', $instance, $this, $args);
So, to make a complete hook, the code is:
Using FirePHP, we see that this filter runs in all widgets being displayed in the frontend, and the following are the values of the widget “Categories”:
The values you are looking for are inside
$args
:And to access
$thiz
values, you’d use: