• Hi,

    My site has a multitude of sidebars that are not intuitively named. I’m attempting to resolve this by editing name in the register sidebar function; the get_sidebar('Sidebar Name') function in the index.php file; and the dynamic_sidebar ('Sidebar Name') function in the sidebar file.

    This works perfectly in the admin area, where the new names now appear and have widgets associated with them, but in the index.php file where I am calling them, it fails. This is not an alignment issue — there is no html output to be found.

    I can provide code if necessary. Any help would be greatly appreciated.

    Thanks,
    Shelton

Viewing 9 replies - 1 through 9 (of 9 total)
  • Are you using register_sidebar or register_sidebars? There’s a big difference. You should be using the latter with multiple sidebars.

    Thread Starter skoskie

    (@skoskie)

    Great question. I wasn’t aware of the plural form of that function… I’ve been using several ‘singulars’. But I think that is what I want given by objective of having intuitive sidebar names. From the page you linked to…

    The only times you might need to call this function instead of register_sidebars() are when you want to give unique names to sidebars, such as “Right Sidebar” and “Left Sidebar”

    Here is how I’ve registered the sidebars…

    register_sidebar(array(
    		'name' => 'Default Right Sidebar',
    		'before_widget' => '<div id="%1$s" class="widget %2$s">',
    		'after_widget' => '</div>',
    		'before_title' => '<h2>',
    		'after_title' => '</h2>'
    	));	
    
    	register_sidebar(array(
    		'name' => 'Homepage Column 1',
    		'before_widget' => '<div id="%1$s" class="widget %2$s">',
    		'after_widget' => '</div>',
    		'before_title' => '<h1>',
    		'after_title' => '</h1>'
    	));

    OK – that code looks fine to me. What’s in your sidebar files?

    Thread Starter skoskie

    (@skoskie)

    It’s a pretty straight forward call:

    <?php get_sidebar('homepage-column-1'); ?>

    … which contains …

    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Homepage Column 1') ) : ?>
    
    <!-- dynamic_sidebar("Homepage Column 1") has failed -->
    
    <?php endif; ?>
    Thread Starter skoskie

    (@skoskie)

    What’s funny is that if I just include the contents of the sidebar-homepage-column-1.php file it works just fine. Should I just delete the file and put a call to the dynamic sidebar in my index.php file.

    Should I be using dynamic_sidebar instead of get_sidebar??

    I hate to ask the obvious but do you have widgets installed in Homepage Column 1?

    Thread Starter skoskie

    (@skoskie)

    Ha. It’s a fair question, but yes I do.

    Thread Starter skoskie

    (@skoskie)

    I think I realized what I’ve done. I assumed that get_sidebar could call the name of the sidebar, rather than the name of the file. I had treated the file name as if it didn’t matter.

    But that begs the question, should the file name matter? Why would I use get_sidebar when I could just use dynamic_sidebar instead?

    Thanks for your help.

    Thread Starter skoskie

    (@skoskie)

    I have to state that the reason for this confusion … and now the cause for even more confusion is that this bit of code works just fine:

    <?php get_sidebar('Homepage Column 4'); ?>

    …and there is no file by that name (sidebar-…..php).

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Dynamic Sidebars Not Working’ is closed to new replies.