Bug fix for custom Left Sidebars on pages, archives, etc.

By UUA Web Team
February 12, 2016, 7:54 pm EST
I discovered today that custom sidebars weren't actually show up in the Left Sidebar on pages, archives, and other content -- this feature was only working for single posts. Pages displayed the default menu built from the page hierarchy, and archives showed nothing.
The problem turns out to be some incorrect logic in the sidebar-left.php template file. The if statement at the top of this file only checks to see whether the post-type is "single". If so, it allows a "dynamic" Left Sidebar. If not, it tries to build the default menu. But actually, that statement should be checking whether the post-type is "page", and then also checking whether a "dynamic" Left Sidebar has been set for that page -- because we only want to build the default menu on pages where we're *not* trying to override the Left Sidebar. To fix this, I added a copy of sidebar-left.php to my child theme's directory and changed the code to reflect the better logic. Here's the new code that worked for me:
<?php if( is_page() && ! is_active_sidebar('sidebar-left') ) { ?>
<?php uuatheme_list_subpages(); ?>
<?php } else { ?>
<?php dynamic_sidebar('sidebar-left'); ?>
<?php } ?> Please add this to the theme for the next update!