Is there a way to call a dynamic sidebar by name rather than ID.

Something like this:

$postName = get_the_category();
   dynamic_sidebar($postName->category_nicename . '_sidebar') ;

2 Answers 2


You can either pass Name or ID of dynamic sidebar to dynamic_sidebar.


  • I tried calling the sidebar by just the name. Even putting it in there statically, but no luck.
    – lz430
    May 19, 2014 at 3:44
  • try print_r($GLOBALS['wp_registered_sidebars']); it should list out all your registered sidebars and you can check if the sidebar you are trying to call is on the list or not.
    – renny
    May 19, 2014 at 5:13

I don't understand your code or what you have done there. From the first answer you commented that the usage in the link doesn't work. My question is, how have you registered your sidebar.

Here is how to properly register a sidebar using register_sidebar taken from the codex.

<?php $args = array(
    'name'          => __( 'Sidebar name', 'theme_text_domain' ),
    'id'            => 'unique-sidebar-id',
    'description'   => '',
        'class'         => '',
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget'  => '</li>',
    'before_title'  => '<h2 class="widgettitle">',
    'after_title'   => '</h2>' ); 

You can either now use the name (Sidebar name) or id (unique-sidebar-id) to call the sidebar to be used

<?php if ( is_active_sidebar( 'Sidebar name' ) ) : ?>
    <ul id="sidebar">
        <?php dynamic_sidebar( 'Sidebar name' ); ?>
<?php endif; ?>


<?php if ( is_active_sidebar( 'unique-sidebar-id' ) ) : ?>
    <ul id="sidebar">
        <?php dynamic_sidebar( 'unique-sidebar-id' ); ?>
<?php endif; ?>

If this doesn't work, then you are going wrong somewhere, because this is how things are done in my theme and in the default wordpress themes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.