1
votes

I have a question about Wordpress register a second sidebar for a new sub-menu i will use for some blog-post on my site.(on a specific-page only)

I read how to Register a new Sidebar! In the first 3 lines of the code below you see what have saved in my themes function__php and it seems to work, i am not shure if is correct, but the Backend shows me now 2 sidebar-areas in the widget-sector.(before there was none i remember)

this i include:

**// If Dynamic Sidebar Exists
if (function_exists('register_sidebars'))
 register_sidebars(2);**
{
// Define Sidebar Widget Area 1
register_sidebar(array(
    'name' => __('Widget Area 1', 'html5blank'),
    'description' => __('Description for this widget-area...', 'html5blank'),
    'id' => 'widget-area-1',
    'before_widget' => '<div id="%1$s" class="%2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h3>',
    'after_title' => '</h3>'
));

// Define Sidebar Widget Area 2
register_sidebar(array(
    'name' => __('Widget Area 2', 'html5blank'),
    'description' => __('Description for this widget-area...', 'html5blank'),
    'id' => 'widget-area-2',
    'before_widget' => '<div id="%1$s" class="%2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h3>',
    'after_title' => '</h3>'
));

// Define Sidebar Widget Area 3
register_sidebar(array(
    'name' => __('Widget Area 3', 'html5blank'),
    'description' => __('Description for this widget-area...', 'html5blank'),
    'id' => 'widget-area-3',
    'before_widget' => '<div id="%1$s" class="%2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h3>',
    'after_title' => '</h3>'
));

}

Now, i am a little bit confused, because in the fist setup of my site there was a widget-area 1! that holds the head-menu, then the widget-area 2! that holds the standart-themes-sidebars: serach field and some widgetized text :P.

now i dont know how to get the second sidebar fully correct registred and how to programm the php in the copyed sidebar2.php

see here:

<!-- Sidebar -->
<aside id="sidebar">

<div class="sidebar-widget3">
<?php if(!function_exists('dynamic_sidebar2') || !dynamic_sidebar('widget-area-3')) ?>
</div>      
</aside>
<!-- /Sidebar -->

should i put the widgets(search-field and text) in my backend in the sidebar-areas or should i leave it in the widget areas?

its a generall-understanding problem for me, amd i hope someone can help me out, because i am a bloody beginner.

tnx a lot.![this is the actuall setup, that is confusing me and i like to have this steps fixed soon...

1

1 Answers

0
votes

First off, remove this line: register_sidebars(2);**
It's unnecessary and might screw it up. Also, your function is named register_sidebars, with an "s" at the end. Since you're using html5blank (so am I,) I can see that this is wrong.

My function looks like this, and it works just fine. Simply replicate the register_sidebar array for as many sidebars that you need. When it comes to "where should I put this-and-that", it's up to you.

if (function_exists('register_sidebar')) {
    register_sidebar(
        array(
            'name'          => __('Widget Area 1', 'html5blank'),
            'description'       => __('Description', 'html5blank'),
            'id'            => 'widget-area-1',
            'before_widget'     => '<div id="%1$s" class="%2$s">',
            'after_widget'      => '</div>',
            'before_title'      => '<h3>',
            'after_title'       => '</h3>'
        )
    );
}

When it comes to sidebar.php, for some reason you have called it dynamic-sidebar2, which is a function that does not exist - unless you've created it.
Simply change it to this:

<div class="sidebar-widget">
    <?php if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('widget-area-1')) ?>
</div>

<div class="sidebar-widget">
    <?php if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('widget-area-2')) ?>
</div>

<div class="sidebar-widget">
    <?php if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('widget-area-3')) ?>
</div>

I hope this answers your question. If it doesn't, leave a comment and I'll try to amend my answer.