Amazing! Without anyone listening, I just rubber-ducked myself into a solution. The names of my template files were wrong. I’ve been tearing my hair out for two hours over a stupid, simple error that is my fault. I’m going to leave this here anyway. Thank you. (Feel free to delete.)
This is probably not CP specific, but good help is more frequent here, so …
I’m building a CP theme from scratch, because existing themes are too complex and I don’t need all the conditionals. I have a basic layout and I am trying to widgetise the sidebar and footer. I have this code in functions.php:
// Register sidebars
add_action( 'widgets_init', 'sidebar_register' );
function sidebar_register() {
register_sidebar(
array(
'name' => __( 'Right Sidebar', 'etp' ),
'description' => __( 'Sidebar on the Right'),
'id' => 's-r',
'class' => ' ',
'before_widget' => ' <div class="sidebar">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
)
);
register_sidebar(
array(
'name' => __( 'Footer Sidebar', 'etp' ),
'description' => __( 'Footer Sidebar' ),
'id' => 's-f',
'class' => ' ',
'before_widget' => ' <div class="sidebar">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
)
);
}
It seems to work, because I can see the widget areas and can add arbitrary text to them.
I added <?php get_sidebar('s-r'); ?> and <?php get_sidebar( 's-f'); ?> to index.php and now the Right sidebar displays what seem to be WP/CP default widgets (Search, Pages, Archive, Categories) and there is nothing at all in the Footer Sidebar.
I have template files called sidebar-right.php and sidebar-footer.php that contain <?php dynamic_sidebar( 's-r' ); ?> and <?php dynamic_sidebar( 's-f' ); ?>
SOLUTION: The files should be called sidebar-s-r.php and sidebar-s-f.php
I have tried everything I can think of. Using the sidebar name instead of id, expanding the id to make it longer, various other permutations.
I have no idea where the default widgets are coming from. The theme I am working on is the only theme in /themes.
I am completely stuck here and hope someone will be able to set me straight.
Thank you
Jeremy