Title: Codex: register_sidebars()
Last modified: August 21, 2016

---

# Codex: register_sidebars()

 *  Resolved [Bego Mario Garde](https://wordpress.org/support/users/pixolin/)
 * (@pixolin)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/codex-register_sidebars/)
 * Couldn’t find a forum section that specially deals with documentation in general–
   or did I miss something?
 * The Codex post for function register_sidebars() has[ a code example (“Default Usage”)](http://codex.wordpress.org/Function_Reference/register_sidebars#Default_Usage)
   that for a couple of reasons doesn’t work as desired if you just copy/paste it:
   
   you get notices for undefined variables, the ID for multiple sidebars would be
   the same and the sprint_f-wrapper function seems to be impractical, too (which
   is actually mentioned in the parameter description underneath – I don’t understand
   though why it it used then anyway).
 * I find this rather confusing but failed to come up with a better code example
   and hence didn’t edit anything. Perhaps someone more skilled can take care of
   it?

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/codex-register_sidebars/#post-4298963)
 * I can only assume that it is your implementation of this example that has caused
   the issues you mention. I’m not sure why you would get warnings about undefined
   variables and there were will no replicated ids due to the use of `%1$s` to generate
   unique ids for every sidebar.
 * > the sprint_f-wrapper function seems to be impractical
 * On what basis?
 *  Thread Starter [Bego Mario Garde](https://wordpress.org/support/users/pixolin/)
 * (@pixolin)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/codex-register_sidebars/#post-4298977)
 * I am referring to [Parameters](http://codex.wordpress.org/Function_Reference/register_sidebars#Parameters)
   where it says under
    “name – Sidebar name. _(Note: If copying from default usage
   above, remove sprintf( ) wrapper function.)_ “
 * Also, I don’t mean the ID being set by parameter ‘before_widget’ but the ‘id’
   => “sidebar-$i”, which in fact doesn’t use %1$s
 * And the notice for undefined variable comes from usage of a variable $i that 
   isn’t declared anywhere before and just seems to appear out of the blue (which
   I find confusing for a documentation).
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/codex-register_sidebars/#post-4298993)
 * > the notice for undefined variable comes from usage of a variable $i that isn’t
   > declared anywhere
 * It’s declared in WordPress core. I’ve used this in dozens of themes without the
   slightest problem.
 *  Thread Starter [Bego Mario Garde](https://wordpress.org/support/users/pixolin/)
 * (@pixolin)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/codex-register_sidebars/#post-4298994)
 * That of course is an argument.
    I surrender.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/codex-register_sidebars/#post-4298995)
 * I did thoroughly re-examine the example you mentioned but, personally, I cannot
   find any reason to change it. Even the sprint_f may be necessary if you are creating
   a translation-ready theme that uses a textdoamin.
 *  Thread Starter [Bego Mario Garde](https://wordpress.org/support/users/pixolin/)
 * (@pixolin)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/codex-register_sidebars/#post-4298999)
 * > I did thoroughly re-examine the example you mentioned…
 * That I have no doubt about and I appreciate your kind attention on the matter.
 * > … , personally, I cannot find any reason to change it.
 * Then let’s just mark this topic as resolved.
 * > Even the sprint_f may be necessary if you are creating a translation-ready 
   > theme that uses a textdoamin.
 * That isn’t mentioned anywhere and introducing a code example just to mention 
   you should remove it in the next line doesn’t seem to be very helpful in a documentation.
   
   Anyhow, I don’t want to argue and if you say it has worked since ages I’ll just
   believe, say ‘thank you’ and we leave everything as is. Sorry for the additional
   work I caused. Won’t happen again.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/codex-register_sidebars/#post-4299005)
 * Hey – no problem! It’s always valid to re-examine default code examples and ensure
   that the Codex documentation is correct & kept up to date. Since anyone can login
   to the Codex and change pages (documentation has always been community project),
   errors can – and often do – creep in. So sanity checks are always a Good Idea(
   tm). 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Codex: register_sidebars()’ is closed to new replies.

## Tags

 * [register_sidebars](https://wordpress.org/support/topic-tag/register_sidebars/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 7 replies
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/codex-register_sidebars/#post-4299005)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
