0
votes

i'm using the Showcase Sidebar with a Text widget. I've inserting some HTML and Text and want that Text widget to display. What PHP code do I insert into the sidebar.php template to show the Text widget and any other ones that I add? Ideal I would like to only load the first Text Widget in from the Showcase Sidebar

would the code look something like this?

<?php if ( !function_exists('dynamic_sidebar')
|| !dynamic_sidebar('sidebar2') ) : ?>
<?php endif; ?>
1
Are you using the standard wordpress text widget? If so, why not append it through the admin interface?Joey

1 Answers

2
votes

yes, it would look something like code you posted:

<?php if ( !function_exists('dynamic_sidebar')
|| !dynamic_sidebar('sidebar2') ) : ?>
<?php endif; ?>

, but -

The code that you posted will only work if you have defined and registered such a sidebar (named : sidebar2)

in your theme´s php you should have a register_sidebar() function call.

if (function_exists('register_sidebar')) {
    register_sidebar(array(
        'name'=> 'Sidebar 2',
        'id' => 'sidebar2',
    ));
}

you can even customize it further with other parameters like .

    'before_widget' => '<li id="%1$s" class="widget %2$s">', 
    'after_widget' => '</li>',
    'before_title' => '<h2 class="offscreen">',
    'after_title' => '</h2>',

If your theme already have such a sidebar defined and registered , then the code you have posted will work and the front side will display all the widgets that you put to that sidebar (on the admin side) . If it is not defined by your theme you will need to define it or ADD it to the definitions of other sidebars .

Read more on the codex here and here about defining sidebars.