How to put a WordPress widget inside a bootstrap navbar?

I am making my first WordPress theme using Bootstrap. Now I want to create a widget area in the far right of my navbar, so I can add ie. a language selector. I tried with the following code, but nothing appears on my site, or in my source code where the widget should be. Any ideas?

  <div class="navbar navbar-inverse navbar-fixed-top">
    <div class="navbar-inner">
      <div class="container">
        <div class="row">
            <div class="span8">
                <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                </a>
                <a class="brand" href="<?php echo site_url(); ?>"><?php bloginfo('name'); ?></a>
                <div class="nav-collapse collapse">
                  <ul class="nav">

                      <?php wp_list_pages(array('title_li' => '', 'exclude' => 4)); ?>

                  </ul>
                </div><!--/.nav-collapse -->
            </div>
            <div class="span4 navbar-right">
                <?php dynamic_sidebar( 'right-top' ); ?></div>
            </div>
        </div>
        </div>
    </div>
  </div>

Code for registering sidebars in functions.php

if ( function_exists('register_sidebar') )
    register_sidebar(array(
        'name'          => 'Right top',
        'id'            => 'right-top',
        'before_widget' => '',
        'after_widget' => '',
        'before_title' => '<h3>',
        'after_title' => '</h3>',
    ));

Related posts

1 comment

  1. When you call register_sidebar you use the name Right top and ID hoyre-top but then call dynamic_sidebar with the name/id right-top which isn’t the ID of that sidebar.

    Try

            <div class="span4 navbar-right">
                <?php dynamic_sidebar( 'hoyre-top' ); ?></div>
            </div>
    

    or change the id of the sidebar in register_sidebar from hoyre-top to right-top.

Comments are closed.