Rename your sidebar files sidebar-accommodation.php, sidebar-see.php, sidebar-directions.php and sidebar-other.php. Then try using:
<?php
<?php if ( is_page('accommodation') ) get_sidebar('accommodation');
elseif ( is_page('see') ) get_sidebar('see');
elseif ( is_page('directions') ) get_sidebar('directions');
elseif ( is_page('16') ) get_sidebar('other');
?>
Umm, I’m getting a little confused with this!?
I’ve changed pages for page ids and called the sidebars 1-4, so it now reads:
<?php if ( is_page(‘4’) ) get_sidebar(‘2’);
elseif ( is_page(’12’) ) get_sidebar(‘2’);
elseif ( is_page(’14’) ) get_sidebar(‘3’);
elseif ( is_page(’16’) ) get_sidebar(‘4’);
?>
It just appears to be bringing in the same sidebar on each page even though I have different widgets on each.
With the sidebar.php files do I simply duplicate the first one and title them sidebar-1.php etc etc.
I’m a bit confused?!
I’ve managed to insert one of the sidebars I created (just to see if they were working!) by using this code:
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-4') ) : ?>
<?php endif; ?>
But I really need differerent sidebars for each of the 4 pages.
I’m at a loss as to know what to do here. I have this:
<?php
if ( is_page('4') ) :
get_sidebar('1');
elseif ( is_page('12') ) :
get_sidebar('2');
elseif ( is_page('14') ) :
get_sidebar('3');
elseif ( is_page('16') ) :
get_sidebar('4');
endif;
?>
and in the functions I’ve created these:
if ( function_exists('register_sidebar') ) {
register_sidebar(array('name'=>'sidebar-1',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
register_sidebar(array('name'=>'sidebar-2',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
register_sidebar(array('name'=>'sidebar-3',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
register_sidebar(array('name'=>'sidebar-4',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
}
The sidebars appear to be showing up okay in my Widgets panel as:
sidebar-1
sidebar-2
sidebar-3
sidebar-4
So I have no idea why it’s not working. It seems to just default to the first sidebar I have?!