Hi
I’m developing a multisite install and it’s my first time using Sage.
I have sidebars throughout the theme and while they all work correctly in the Main parent site, the sub-sites don’t appear to be saving any widget data, merely showing default widget content.
The same theme is used for all sites, parent and sub sites, and everything works 100% on the parent site with the same code. Is there anything I need to do to enable sidebars to work on Network sub-sites in init.php?
Sidebars in the widgets page are there, but any widgets placed inside them on a sub-site doesn’t save the widget at all.
Here’s my code:
init.php
/**
* Register sidebars
*/
function widgets_init() {
register_sidebar([
'name' => __('Footer Col 1', 'sage'),
'id' => 'footer-1',
'before_widget' => '<section class="widget fc1 %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h4>',
'after_title' => '</h4>'
]);
register_sidebar([
'name' => __('Footer Col 2', 'sage'),
'id' => 'footer-2',
'before_widget' => '<section class="widget fc2 %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h4>',
'after_title' => '</h4>'
]);
register_sidebar([
'name' => __('Footer Col 3', 'sage'),
'id' => 'footer-3',
'before_widget' => '<section class="widget fc3 %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h4>',
'after_title' => '</h4>'
]);
register_sidebar([
'name' => __('Footer Col 4', 'sage'),
'id' => 'footer-4',
'before_widget' => '<section class="widget fc4 %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h4>',
'after_title' => '</h4>'
]);
register_sidebar([
'name' => __('Footer Social', 'sage'),
'id' => 'footer-5',
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h4>',
'after_title' => '</h4>'
]);
}
add_action('widgets_init', __NAMESPACE__ . '\\widgets_init');
…and then calling it in the theme template file:
<?php if ( is_active_sidebar('footer-1') ) : ?>
<div class="col-sm-3">
<?php dynamic_sidebar('footer-1'); ?>
</div>
<?php endif; ?>
<?php if ( is_active_sidebar('footer-2') ) : ?>
<div class="col-sm-3">
<?php dynamic_sidebar('footer-2'); ?>
</div>
<?php endif; ?>
<?php if ( is_active_sidebar('footer-3') ) : ?>
<div class="col-sm-3">
<?php dynamic_sidebar('footer-3'); ?>
</div>
<?php endif; ?>
<?php if ( is_active_sidebar( 'footer-4') ) : ?>
<div class="col-sm-2">
<?php dynamic_sidebar('footer-4'); ?>
</div>
<?php endif; ?>
<?php if ( is_active_sidebar('footer-5') ) : ?>
<div class="col-sm-1 footer-social">
<?php dynamic_sidebar('footer-5'); ?>
</div>
<?php endif; ?>
… as I say, it works great on the main parent site, all widgets update correctly, but none are working on the sub-sites.
Any ideas would be appreciated or if anyone has experienced anything similar, was there a fix?