Even if this plugin is not updated, the architecture of WordPress poor sidebar handling has not changed, and this lite plugin works well. Shu Shu train!
]]>Hey I posted this on your blog, but thought this might be a better place for it:
I’m wondering if it’s possible to add support for the sidebar id to be included for filtering. I know id
is a paramater of dynamic_sidebar_params
, but I can’t figure out how to integrate it.
This is what I’d like be able to do:
function my_widget_output_filter( $widget_output, $widget_type, $widget_id, $sidebar_id ) {
if ( 'categories' == $widget_type && 'primary-sidebar' == $sidebar_id ) {
$widget_output = str_replace('before', 'after', $widget_output);
}
return $widget_output;
}
add_filter( 'widget_output', 'my_widget_output_filter', 10, 3 );
This would allow filtering on only specific widgets of specific sidebars instead of executing on every sidebar on the site.
]]>First off this plugin is incredible for anyone reading this. It’s definitely being overlooked by many on wordpress (I’m guessing because most people don’t understand it). I read the blog post explaining it and I completely agree something like this needs to be added to wordpress core.
For people who aren’t sure how to use….
Here are the “Core Widget Types” available for filtering
You can figure this out by going to your wp-admin/widgets.php. Once there open up your broswer developer tools to view the source.
In the image above you’ll notice each widget I added to the sidebar. The highlighted one on that screenshot is the search widget and in this case has an id of widget_55-search-12
So with that information we know the widget ID is search-12 and the widget type is search.
So now here’s an example:
If you reference that screenshot again you’ll see that the search widget has an id of widget_59-calendar-7
.
So in this case calendar
is our widget type and and calendar-7
is the widget id. Let’s say you are using bootstrap in your theme and want to style the calendar with bootstraps table classes. This is how you’d add them….
Using the widget type:
function my_widget_output_filter( $widget_output, $widget_type, $widget_id ) {
if ( 'calendar' == $widget_type ) {
$widget_output = str_replace('<table id="wp-calendar', '<table class="table table-responsive table-condensed" id="wp-calendar', $widget_output);
}
return $widget_output;
}
add_filter( 'widget_output', 'my_widget_output_filter', 10, 3 );
Using the widget id:
function my_widget_output_filter( $widget_output, $widget_type, $widget_id ) {
if ( 'calendar-7' == $widget_id ) {
$widget_output = str_replace('<table id="wp-calendar', '<table class="table table-responsive table-condensed" id="wp-calendar', $widget_output);
}
return $widget_output;
}
add_filter( 'widget_output', 'my_widget_output_filter', 10, 3 );
Hope this helps some people out.
]]>A picture paints a thousand words
]]>