0

Problem My sidebar is not displaying in the Wordpress footer.php file.

functions.php

<?php
add_action( 'widgets_init', 'social_media_sidebar' );
function social_media_sidebar() {
  register_sidebar( array(
        'name'          => 'Social Media Sidebar Widgets',
        'id'            => 'social_media_sidebar_widgets',
        'before_widget' => '<div>',
        'after_widget'  => '</div>',
        'before_title'  => '<span style="display:none;">',
        'after_title'   => '</span>',
  ));
}
?>

sidebar.php

<div class="sidebar">
    <?php dynamic_sidebar( 'social_media_sidebar_widgets' ); ?>
</div>

footer.php

<?php get_sidebar( 'social_media_sidebar_widgets' ); ?>

Note - the above footer.php call is not in a loop. That's the only thing I can think of that may be causing the widget to not display? I'm using the same call to get_sidebar in 3 other template files (within the loop) and they load just fine. I just can't get it to display in the footer. Nothing is being hidden with CSS.

What can I do to get the social_media_sidebar_widgets sidebar to display in my footer?

2

The declaration in your footer tells WordPress to find the sidebar-social_media_sidebar_widgets.php file and apply it there.

I think what you want is to declare:

<?php dynamic_sidebar( 'social_media_sidebar_widgets' ); ?>

in your footer.php file.

  • a ha! that did the trick. Thank you, @Ryan! (will accept this answer once the time restriction passes) – Joe Jun 20 '17 at 20:33
  • All good, my friend! Glad I could be of help :-) – Ryan Jun 20 '17 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.