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

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

Hooking a function onto the sidebar?

Load at the sidebar bottom In most of the sidebars, you’ll find the call to the wp_meta() action hook, where you can hook into the (mostly bottom) of a sidebar. Load on top of your sidebar The function get_sidebar( $name ) calls the sidebar you want in your template (this allows to have different sidebars). … 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; }

Display Random Author with Details in Sidebar

Your best option is to get a random post author which is a user ID so here is a function to do just that: function get_random_author_wpa91320(){ global $wpdb; $id = $wpdb->get_var(” SELECT post_author FROM $wpdb->posts WHERE post_type=”post” AND post_status=”publish” ORDER BY RAND() LIMIT 1 “); return $id; } And once you have that function in … Read more

Best way of making multiple sidebars

Defining new sidebar with in your functions.php <?php if ( function_exists(‘register_sidebar’) ) { register_sidebar(array( ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2>’ )); }?> Once these are functions are defined, you will notice the extra sidebar appear in the WordPress Dashboard under the Appearance > Widgets option. … Read more