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 =
I agree with Michael and also, I’m not sure how your functions are set up but usually I’d see something more similar to