WordPress.org

Ready to get started?Download WordPress

Forums

M footer widgets disappear when I add a new sidebar widget... (14 posts)

  1. jstudios
    Member
    Posted 1 year ago #

    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>",
    ));
  2. jstudios
    Member
    Posted 1 year ago #

    Still happening.

  3. esmi
    Forum Moderator
    Posted 1 year ago #

    What theme are you using? Where did you download it from?

  4. jstudios
    Member
    Posted 1 year ago #

    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.

  5. esmi
    Forum Moderator
    Posted 1 year ago #

    How are you calling the footer widgets in footer.php?

  6. jstudios
    Member
    Posted 1 year ago #

    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>
  7. esmi
    Forum Moderator
    Posted 1 year ago #

    What happens if you remove the <?php if ( isset( $options['showfooterwidgets'] ) ) { ?> conditional?

  8. jstudios
    Member
    Posted 1 year ago #

    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.

  9. esmi
    Forum Moderator
    Posted 1 year ago #

    It sounds like there's an issue with the value in your theme option. Have you tried echoing its value out to the page?

  10. jstudios
    Member
    Posted 1 year ago #

    I did the following and the output is "1".

    <?php echo $options['showfooterwidgets']; ?>

  11. esmi
    Forum Moderator
    Posted 1 year ago #

    Assuming a value of 1 means "show widgets", try:

    <?php if ( isset( $options['showfooterwidgets'] ) && $options['showfooterwidgets'] == 1 ) { ?>

  12. jstudios
    Member
    Posted 1 year ago #

    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!!!

  13. esmi
    Forum Moderator
    Posted 1 year ago #

    Glad to hear that it's working so far.

  14. jstudios
    Member
    Posted 12 months ago #

    It's happening again... :(

Topic Closed

This topic has been closed to new replies.

About this Topic