newbie
newbie

Reputation: 1

Wordpress widgets in my theme

I am new here as well as in web development :) I have a question about wordpress. I try to make sidebar-widgets.

In my sidebar.php file I write:

<div id="sidebar">

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

<div>some html here </div>

<?php endif; ?>

and in function.php

<?php
if ( function_exists('register_sidebars') )
    register_sidebar();
?>

But it does not appear in widgets list, but when I click appearance-widget, in right part it appears Sidebar 1, and I can't even move it.

Can you please help me how to do it? Thanks

Upvotes: 0

Views: 74

Answers (1)

The Alpha
The Alpha

Reputation: 146269

In your functions.php

if ( function_exists('register_sidebar') ){
    register_sidebar(array(
        'name' => 'Sidebar',
        'id' => 'sidebar_widget_1',
        'description' => 'Widgets in this area will be shown in the sidebar.',
        'before_widget' => '<div id="%1$s" class="%2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h2>',
        'after_title' => '</h2>'
    )
);

In your sidebar.php

<div id="sidebar">
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar') ) : ?>
        <div>some html here </div>
    <?php endif; ?>
</div>

Upvotes: 1

Related Questions