How to use
-
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
- archives
- calendar
- categories
- meta
- nav_menu
- pages
- recent-comments
- recent-posts
- rss
- search
- tag_cloud
- text
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 andcalendar-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.
- The topic ‘How to use’ is closed to new replies.