Changing name of sidebar widget

Use the ‘Name’ parameter in your register_sidebar call. E.g., see the following code in the default Twenty Ten theme, line 351. function twentyten_widgets_init() { // Area 1, located at the top of the sidebar. register_sidebar( array( ‘name’ => __( ‘Primary Widget Area’, ‘twentyten’ ), ‘id’ => ‘primary-widget-area’, ‘description’ => __( ‘The primary widget area’, ‘twentyten’ … Read more

How to wrap the widget content with a div or get the widget title outside?

this is the solution to wrap the content after the title like this ‘before_widget’ => ‘<li>’, ‘after_widget’ => ‘</div></li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2><div class=”widgetcontent”>’ ); ?> the important markup is the <div class=”widgetcontent>” in the after_title, and the closing </div> in the after_widget, this will result in this html markup: <ul> <li> … Read more

Having different sidebar content for MANY pages?

You could dynamically register sidebars. When you register sidebars, you could query for all of your animal pages, loop over all pages, and register a unique sidebar for each page. Adding a page would automatically create a sidebar for it. However – that’s a lot of sidebars. For something tightly coupled with the page content, … Read more

Highlight custom widgets in the admin area?

All widgets in the admin area get an id in the style widget-[global_counter]_[widget_key]-[widget_id], like widget-59_monkeyman_widget_shortcut-5 (installed widget) or widget-11_monkeyman_widget_shortcut-__i__ (an uninstalled widget in the list). If your widget key contains something unique for all your widgets (like your company name), you can use this and add a substring attribute CSS selector (which works in most … Read more

HowTo: Add Class to Sidebar Widget List-Items

Update: 12/19/15 : Here’s a plugin on Github that I developed (using the method in answer I provided below) adding support for changing all widget to bootstrap components/styling. Original Answer I understand not wanting to use javascript, but it seems like overkill in my opinion to completely create a new widget just for the list-group … Read more

How To Determine If A Filter Is Called In A Sidebar/Widget Context?

On a parallel thread over on the WordPress hacks forum, someone suggested using in_the_loop() and that works some of the time, with some plugins that use either the_content and/or the_excerpt, but not all of the time with all the plugins I’ve been testing against. Likewise, I’ve now done further testing using is_main_query() and that works … Read more

Show Woocommerce minicart widget in checkout page sidebar? And, how to make this update secure by overriding widget?

The cart widget isn’t showing because it’s configured to not show on the cart and checkout page. If you want to change that take a look at class-wc-widget-cart.php, there you find the following line: if ( is_cart() || is_checkout() ) return; Change it to: if ( is_cart() ) return; To show the widget on the … Read more

How Do I Add Custom CSS To Only Certain Widgets

Hi John: I think this is what you are looking for (I’d explain the code be I think it’s self-explanatory; let me know if not): <?php add_filter(‘dynamic_sidebar_params’,’my_dynamic_sidebar_params’); function my_dynamic_sidebar_params($params) { $sidebar_id = $params[0][‘id’]; $sidebar_widgets = wp_get_sidebars_widgets(); $last_widget_id = end($sidebar_widgets[$sidebar_id]); if ($last_widget_id==$params[0][‘widget_id’]) $params[0][‘before_widget’] = str_replace(‘ class=”‘,’ class=”last_widget ‘,$params[0][‘before_widget’]); return $params; }