M footer widgets disappear when I add a new sidebar widget…
-
I just noticed that all 4 of my footer widgets disappear when I add a widget to either one of the 2 sidebars. Is there a common cause for this?
This is in my functions.php file (custom theme I am developing):
/* Main Sidebars **************** Registering the primary and secondary sidebars for 2 and 3 column layouts *************************************************************************/ register_sidebar(array( 'name' => __( 'Primary Sidebar' ), 'id' => 'primary-sidebar', 'description' => '', 'class' => '', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => "</li>\n", 'before_title' => '<h4 class="widgettitle">', 'after_title' => "</h4>\n", )); register_sidebar(array( 'name' => __( 'Secondary Sidebar' ), 'id' => 'secondary-sidebar', 'description' => '', 'class' => '', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => "</li>\n", 'before_title' => '<h4 class="widgettitle">', 'after_title' => "</h4>\n", )); /* Footer Widget Areas ********************** Registering the 4 widget areas of the footer ********************************************/ register_sidebars(4, array( 'name' => __('Footer %d'), 'id' => 'footerwidget-$i', 'description' => '', 'class' => '', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => "</li>", 'before_title' => '<h4 class="widgettitle">', 'after_title' => "</h4>", ));
-
Still happening.
What theme are you using? Where did you download it from?
My own, I built my own parent theme to use on clients. Let me know what you need.
Theme works just as I need, expect the footer widgets issue.
How are you calling the footer widgets in footer.php?
Here is my footer.php in its entirety:
<span class="clearfix"></span> </div><!-- #main --> <?php $options = get_option( 'jframe_theme_options' ); ?> <footer id="footer"> <?php if ( isset( $options['showfooterwidgets'] ) ) { ?> <section id="footer-widgets"> <?php dynamic_sidebar('Footer 1'); dynamic_sidebar('Footer 2'); dynamic_sidebar('Footer 3'); dynamic_sidebar('Footer 4'); ?> <span class="clearfix"></span> </section><!-- #footer-widgets --> <?php } ?> <div id="footer-container"> <div id="footer-content" class="leftFooterContent"> <?php if ( isset( $options['leftfootercontent'] ) ) { echo do_shortcode( $options['leftfootercontent'] ); } ?> </div> <div id="footer-content" class="rightFooterContent"> <?php if ( isset( $options['rightfootercontent'] ) ) { echo do_shortcode( $options['rightfootercontent'] ); } ?> </div> <div id="footer-content" class="middleFooterContent"> <?php if ( isset( $options['middlefootercontent'] ) ) { echo do_shortcode( $options['middlefootercontent'] ); } ?> </div> </div><!-- #footer-container --> <span class="clearfix"></span> <?php wp_footer(); ?> </footer><!-- #footer --> </div><!-- #wrapper --> </body> </html>
What happens if you remove the
<?php if ( isset( $options['showfooterwidgets'] ) ) { ?>
conditional?I have a whole div container dedicated to the footer widgets. Under Theme Options I can elect if I wish to enable the footer widgets or not. That conditional will display the footer widgets area if checked under Theme Options. That way, if someone doesn’t wish to use footer widgets, there won’t be an empty div at the bottom, but instead it will be removed completely.
I removed it and everything works fine, I even added a widget to the main sidebar without losing the footer widgets. But I WILL be needing that conditional because of the way the theme is built.
It sounds like there’s an issue with the value in your theme option. Have you tried echoing its value out to the page?
I did the following and the output is “1”.
<?php echo $options['showfooterwidgets']; ?>
Assuming a value of 1 means “show widgets”, try:
<?php if ( isset( $options['showfooterwidgets'] ) && $options['showfooterwidgets'] == 1 ) { ?>
Alright, I did that and added a main widget successfully without loosing the footer widgets. I’ll keep an eye out on how it works out and if I have any issues I’ll rebump the thread.
Many thanks!!!
Glad to hear that it’s working so far.
It’s happening again… π
- The topic ‘M footer widgets disappear when I add a new sidebar widget…’ is closed to new replies.