Duplicate and change a Theme Widget

Widgets extend the Widget Class, search in the theme code for a class that extends WP_Widget. Copy/Paste it, rename it, and change what you’d like. You can also look in the file wp-includes/default-widgets.php and use one of those as a starting point.

How to place random widgets in the WordPress sidebar?

Here comes the workaround solution discussed in the comments: functions.php: add_action( ‘widgets_init’, ‘talfluxive_register_sidebars’ ); function talfluxive_register_sidebars() { // register five random widget areas register_sidebars( 5, array( ‘name’ => ‘Random Widget Area %d’ ) ); // register two fixed widget areas register_sidebars( 2, array( ‘name’ => ‘Fixed Widget Area %d’ ) ); } sidebar.php dynamic_sidebar( ‘Fixed … Read more

Add a select box to all widgets

Thanks to Ed Nailor & Kucrut ! http://ednailor.com/2011/01/24/adding-custom-css-classes-to-sidebar-widgets/ // __________________________________________________________ // // CUSTOM CLASS BY WIDGETS function kc_widget_form_extend( $instance, $widget ) { if ( !isset($instance[‘classes’]) ) $instance[‘classes’] = null; /* Set your predetermied class choices here */ $myarray = “class1,class2,class3”; $myclasses = explode(“,”,$myarray); $row = “\n”; $row .= “\tid_base}-{$widget->number}-classes’>Class:\n”; $row .= “\tid_base}[{$widget->number}][classes]’ id=’widget-{$widget->id_base}-{$widget->number}-classes’ class=”widefat”>\n”; foreach($myclasses … Read more

remove from text-widget

OK, attempting to remove the with jQuery is counter intuitive. Modifying it via output buffering is inefficient. And we shouldn’t edit the actual widget code itself, since this will revert back next time we update WordPress. I would suggest either creating your own text widget, or simply extend and modify the existing WordPress widget as … Read more

What is the use case for the “Class” parameter in register_sidebar?

If you fill class parameter to register_sidebar function then the class sidebar-{class name} gets added to the div of that sidebar in the back end. For example if you register the sidebar using following code : register_sidebar( array( ‘name’ => __(‘Footer Widget One’, ‘wpbs-framework’), ‘id’ => ‘footer-01’, ‘class’ => ‘testing’, ‘description’ => __(‘The first footer … Read more

Which settings/options are saved on a theme-basis and how does this affect theme-switching?

After doing some research this answer became a bit longer than expected, but this is the essence: TL;DR: Menu placement and Widget placement/order is saved on a Theme basis and can therefore be restored when switching Themes. This does not include the individual settings of Menus and Widgets, so if you change them these changes … Read more

Unregistering a Sidebar in Child Theme

It should be possible to use the after_setup_theme hook to unregister the sidebar you don’t want like this: function go_away_extra_sidebar(){ unregister_sidebar( ‘Footer’ ); } add_action( ‘after_setup_theme’, ‘go_away_extra_sidebar’ ); Happy Coding, Kuchenundkakao

use add_action(‘wp_head’) in a widget for generating dynamic CSS styles

Once the widgets are being evaluated, the head of your site is completed, so you cannot use wp_head anymore. Adding <style> tags is an option, but will indeed generate a warning from the validator. Using the customizer is possibly confusing, because it is supposed to be about theme looks in general, not about specific widgets. … Read more