WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a new sidebar. For that I have used the following code:

In functions.php

if ( function_exists('register_sidebar') )

if ( function_exists ('register_sidebar')) {
register_sidebar ('sidebar-custom');

Then I created a file called sidebar-custom.php.The code for that file is as follows

<ul class=”sidebar”>
     <?php if ( !function_exists('dynamic_sidebar') ||
           !dynamic_sidebar('sidebar-custom') ) : ?>
     <?php endif; ?>

But the sidebar area is not visible in the dashboard.I know I have done something terribly wrong. But dont know what it is. Can anyone help?

share|improve this question

Two problems. To register the sidebar you need to pass a minimum of the 'id'.

if ( function_exists ('register_sidebar')) {

Despite the Codex, I cannot get the sidebar to show up using only register_sidebar('custom');

That will make the sidebar show up on the backend. See the Codex for other parameters.

Secondly, there is nothing to load sidebar-custom.php. dynamic_sidebar('custom') would load a file named sidebar-custom.php, at least the Codex appears to suggest that, but since you have that function call inside sidebar-custom.php it never gets to run.

Third, you have curly quotes in you code. Look at the quotes around the class name.

So, to make this work put the following in functions.php (same as above):

if ( function_exists ('register_sidebar')) {

Place the following in the template file where you want to the sidebar to load but not in sidebar-custom.php.

 if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('custom') ) :

Your sidebar should now work, but again despite the Codex or possibly the Codex is just very confusing on the point, I can't get your sidebar-custom.php file to load.

To do that I have to explicitly use get_sidebar ('custom');

The more I worked on this, the more I came to believe that the Codex is poorly written when it come to custom sidebar files. The truth is in there but it is hard to see. Hope this helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.