The question is regarding, calling the default widgets into the sidebar[s]:
So, despite the solution given in THIS THREAD, I tried a different way – Ian Stewart’s borrowed solution given HERE.
It’s like, declaring the following lines into functions.php
, suppose I have two different sidebars in my theme:
// Preset Widgets
$preset_widgets = array (
'primary_widget_area' => array( 'search', 'pages', 'categories', 'archives' ),
'secondary_widget_area' => array( 'links', 'meta' )
);
if ( isset( $_GET['activated'] ) ) {
update_option( 'sidebars_widgets', $preset_widgets );
}
//update_option( 'sidebars_widgets', NULL );
// Check for static widgets in widget-ready areas
function is_sidebar_active( $index ){
global $wp_registered_sidebars;
$widgetcolums = wp_get_sidebars_widgets();
if ($widgetcolums[$index]) return true;
return false;
} // end is_sidebar_active
The problem is, my theme is NOT calling the default widgets in absence of any widgets at the beginning. I can’t fix it, because I can’t understand the code above and obviously the process explained by Ian Stewart.
And also, can’t understand the explanation regarding //update_option( 'sidebars_widgets', NULL );
.
How can I fix this?
I solved the issue using a fallback with PHP conditionals: in my
sidebar.php
I coded like the following: