0
votes

I am creating a WP-theme, and run into a problem. I want to have dynamic sidebars with widgets, and therefore created sidebar.php like this

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

<?php endif; ?>

And in functions.php i wrote this

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

Now, wordpress says on the "Themes" page that under functions, widgets is available, but when i navigate to the widgets-section i get the error "No sidebars defined". In my index.php i have added the line "get_sidebar()".

What could cause this, and how do i solve it?

1

1 Answers

1
votes

Try assigning a name to the registered sidebar like this:

<?php register_sidebar(array('name'=>'sidebar1', )); ?>

Then call it in the template file like this:

<?php if ( function_exists ( dynamic_sidebar(1) ) ) : ?>
<?php dynamic_sidebar (1); ?>
<?php endif; ?>