• Phil

    (@owendevelopment)


    Hi

    I’m developing a multisite install. 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. Is there anything I need to do to enable sidebars to work on Network sub-sites also?

    I’m using Roots Sage theme.

    Here’s my code:

    functions.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 calling it in the theme e.g:

    <?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, but none working on the sub-sites. Please help.

Viewing 1 replies (of 1 total)
  • I’ll offer what may be a dumb answer.

    To set theme widget options on a sub site you have to change the appearance settings on that site, each and every site. It appears in your post that you expect to change widget settings on the main site and have widgets change on every subsite. It is not so easy. Each site has its own set of options, and widget settings are just like the rest.

    Now if you indeed are visiting each separate site to attempt to save settings, but they are not saving, then indeed you have something amiss.

Viewing 1 replies (of 1 total)
  • The topic ‘Widgets not saving/registering in Network sub-sites only’ is closed to new replies.