Search code examples
phpwordpresswordpress-themingsidebar

Registered WordPress Sidebar not showing


I have a sidebar in WordPress I've registered like so:

register_sidebar(array(
    'id' => '404',
    'name' => __('404', 'jointstheme'),
    'description' => __('The 404 sidebar.', 'jointstheme'),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="widgettitle">',
    'after_title' => '</h4>',
));

I duplicated my existing 'sidebar.php' file and created a file called: sidebar-404.php.

I also added the call to my sidebar in the 404 page template like so:

<?php get_sidebar('404'); ?>

Yet for some reason, my theme keeps defaulting to the default sidebar.

Anyone have any ideas what might be going on?

Thanks!


Solution

  • When you register a sidebar in your functions.php file and want to use the widget manager in from the admin panel, you need to use dynamic siderbars not get_sidebar. get_sidebar will only display the widgets that are coded into the file.

    Instead of <?php get_sidebar('404'); ?> you should have something like <?php dynamic_sidebar( '404' ); ?>