I've been pulling my hair out today trying to get this right. Basically I have a sidebar, which makes requests to individual files (such as sidebar-home.php, sidebar-residential.php) and different dynamic menus are supposed to be loaded depending on what page you're on.
Previously this has been easy to set up when moving between: is_page, is_single, is_category, is_archive etc... But, as I have read, is_page keeps returning as true, despite any reset or endif condition.
Would love to hear some feedback on what I am doing wrong here. How can I get is_page(24) and is_page(36) to see different parts of the sidebar?
Code is below
<?php if (is_page('189')) :
get_sidebar('home');
elseif (is_page() && !is_page(array('189','24','36',is_tree('24'),is_tree('36')))) :
get_sidebar('page');
elseif (is_page('24') && !is_page(array('36')) || is_tree('24') || is_or_descendant_tax('6','product_category') || is_or_descendant_tax('6','topic')) :
get_sidebar('residential');
elseif (is_page(array('36')) && !is_page(array('24')) || is_tree('36') || is_or_descendant_tax('15','product_category') || is_or_descendant_tax('5','topic')) :
get_sidebar('utility');
elseif (is_post_type_archive('download_type')) :
get_sidebar('download');
endif; ?>