Sidebar WP widget

Ok, so this works and all is well. But I can’t understand why it works:

In my functions.php i have:

Read More
register_sidebar( array(
 'name' => 'Welcome',
 'id' => 'Welcome',
 'before_widget' => '',
 'after_widget' => '',
 'before_title' => '<h1>',
 'after_title' => '</h1>',
) );

No weird stuff there. But in my loop file I have this, and I can’t understand why it outputs a widget:

<div class="large-4 columns welcomeText sidebar">
  <?php if ( dynamic_sidebar('Welcome') ) : ?>
  <?php endif; ?>
</div>

The if-statment says if there is a dynamic sidebar “Welcome” do nothing???

Related posts

Leave a Reply

1 comment

  1. You call dynamic_sidebar( $index ) to displays the registered sidebar.
    What gets displayed is the content of that registered sidebar widget located at DashBoard > Appearance > Widgets and the function returns true on success and false on failure.

    From WordPress Codex:

    The return value should be used to determine whether to display a
    static sidebar. This ensures that your theme will look good even
    when the Widgets plug-in is not active.

    So your code should actually be

    <?php if ( !dynamic_sidebar('Welcome') ) : ?>