I'm developing Wordpress theme for my friend's company, but this question is all about PHP so writing here, on SO.
I have two sidebars, that's how we display sidebars in Wordpress:
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('SidebarName') ) :
endif;
So that's an if statement.
Ok, now, I want to display ONE sidebars IF $layout="one" TWO sidebars IF $layout=="two" etc.
This code works, but it duplicates sidebars contents I believe endifs are messing with the parent loops or something like that:
if($layout="one") {
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar 1') ) :
endif;
} elseif($layout=="two") {
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(' Sidebar 1') ) :
endif;
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar 2') ) :
endif;
} elseif($layout=="three") { (...)
How to fix that issue? When I just delete the main if loop - everything work like expected, so I'm sure I got lost somewhere above.
Sorry, typos, I'm using $layout== instead of =
ifloop. What do you mean with mainifloop? The outerifstatement? What are the functions doing? Seems pretty useless to me (and unintuitive), to have emptyifstatements (or are you not showing the content of theifstatements)?if loopsI think you meannested if statements