Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
if ( function_exists('register_sidebar') )
    register_sidebar(array(
        "name" => "Top Widget Area",
        "id" => "topWidgetArea-$i",
    ));

I just create a new sidebar with this.
I'm displaying this sidebar in my header.php like this:

<?php dynamic_sidebar( "Top Widget Area" ); ?> 

It's displaying no problem and I can put every widget to my sidebar in wp-admin's Appearance → Widgets page. When I refresh this widgets page, all the widgets (which are in the Top Widget Area) are disappearing. I'll explain it with a video. Please check: http://screenr.com/szG8

share|improve this question
add comment

4 Answers

up vote 2 down vote accepted

Changing widget's ID from topWidgetArea to top-widget-area solved my problem. Widget ID must have hypen. I tried a lots of variations for ID (like testtesttest, asdasdasd, widgetareaaa) . I'm not sure, why .

share|improve this answer
    
No capitals are allowed either. –  MrJD Jun 29 '12 at 5:01
add comment

You are not allowed capitals that is why it doesn't work.

Use a name like this-dynamic-sidebar or this_dynamic_sidebar. It should be the same name used when you registered the sidebar.

share|improve this answer
    
That is not exactly true. I have have used capital letters in my theming for sidebars and have had no problems. To me with this site it seems to me to be a caching issue. –  Nicole Oct 18 '12 at 18:14
add comment

It is the variable $i that is the issue, causing probably a php error because it is not defined.

Just had the same issue. Removing the id prams solved the issue.

share|improve this answer
add comment

Parameters for register_sidebar, from http://codex.wordpress.org/Function_Reference/register_sidebar#Parameters:

id - Sidebar id - Must be all in lowercase, with no spaces (default is a numeric auto-incremented ID).

Hyphens and underscores are not required. Just no uppercase, no spaces.

share|improve this answer
add comment

Your Answer

 
discard

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.