Using sidebar-2 and sidebar-3 on all pages?
-
Hi Tomas, I’ve been trying to edit the child theme so that I can use sidebar-2 and sidebar-3 on all pages if I want, not just with the front page template. I’ve sort of got it working by pretty much replacing the contents of sidebar.php with the contents of sidebar-front.php and editing it slightly.
Below is what I ended up with – I added sidebar-1 as well just to try it but I don’t know if I will use it as well, and I changed the ids. It seems to work fine but only if I add a widget to the Main (sidebar-1). If the Main widget area is empty nothing appears in the sidebar area at all, is that correct? If so, not a problem I can add an empty text widget and stop it displaying.
I also didn’t know whether I should add sidebar-1 to the first if along with 2 and 3?
I tried that and it did not fix the non display issue.
Or am I doing this all wrong? Quite possibly :-).
Hope you can help, David
<?php if ( ! is_active_sidebar( 'sidebar-2' ) && ! is_active_sidebar( 'sidebar-3' ) ) return; // If we get this far, we have widgets. Let do this. ?> <div id="secondary" class="widget-area" role="complementary"> <?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?> <div id="main_wrapper"> <?php dynamic_sidebar( 'sidebar-1' ); ?> </div><!-- .first --> <?php endif; ?> <?php if ( is_active_sidebar( 'sidebar-2' ) ) : ?> <div id="sidebar_wrapper"> <?php dynamic_sidebar( 'sidebar-2' ); ?> </div><!-- .first --> <?php endif; ?> <?php if ( is_active_sidebar( 'sidebar-3' ) ) : ?> <div id="sticky_sidebar_wrapper"> <?php dynamic_sidebar( 'sidebar-3' ); ?> </div><!-- .second --> <?php endif; ?> </div><!-- #secondary -->
- The topic ‘Using sidebar-2 and sidebar-3 on all pages?’ is closed to new replies.