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.

I am want to register a sidebar but i am a little confused about the uses of the id argument in register_sidebar function.

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

Of what use is the id arguement and must it alyways be in numeric form?.

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

The sidebar ID is used to uniquely identify this specific sidebar. If you don't set it and something creates another, you could find that your sidebar moves somewhere unexpected!

It doesn't need to be numeric - you can use strings, too.

share|improve this answer
add comment

John Landells’ answer is good and correct.

I want to add a List of forbidden or reserved IDs – these IDs may appear on the widget config page /wp-admin/widgets.php. If you use one of these … strange things will happen due to duplicated IDs. Drag and drop will probably not work anymore. See Ticket #14466 for the most obvious case: #footer.

Update, Sept. 17.: #footer will be allowed in WP 3.5.
Update, Nov., 06.: Per ticket 14466 all widget IDs in widgets.php are prefixed with sidebar- now. The following list will be obsolete with WordPress 3.5. Probably.

Also, an ID should not start with a number, that’s invalid HTML.

Installed plugins affecting this list: Debug Bar, Debug Bar Cron, Monster Widget.

#_wpnonce_widgets
#ab-awaiting-mod
#access-off
#access-on
#adminmenu
#adminmenuback
#adminmenushadow
#adminmenuwrap
#adv-settings
#available-widgets
#collapse-button
#collapse-menu
#colors-css
#contextual-help-back
#contextual-help-columns
#contextual-help-link
#contextual-help-link-wrap
#contextual-help-wrap
#debug-bar-actions
#debug-bar-cron
#debug-bar-css
#debug-bar-info
#debug-bar-menu
#debug-bar-wp-query
#debug-menu-link-Debug_Bar_Object_Cache
#debug-menu-link-Debug_Bar_Queries
#debug-menu-link-Debug_Bar_WP_Query
#debug-menu-link-ZT_Debug_Bar_Cron
#debug-menu-links
#debug-menu-target-Debug_Bar_Object_Cache
#debug-menu-target-Debug_Bar_Queries
#debug-menu-target-Debug_Bar_WP_Query
#debug-menu-target-ZT_Debug_Bar_Cron
#debug-menu-targets
#debug-status
#debug-status-db
#debug-status-memory
#debug-status-php
#debug-status-site
#footer
#footer-left
#footer-thankyou
#footer-upgrade
#icon-themes
#menu-appearance
#menu-comments
#menu-dashboard
#menu-links
#menu-media
#menu-pages
#menu-plugins
#menu-posts
#menu-posts-domicile
#menu-settings
#menu-tools
#menu-users
#object-cache-stats
#querylist
#removing-widget
#rss-items-2
#rss-items-__i__
#rss-show-author-2
#rss-show-author-__i__
#rss-show-date-2
#rss-show-date-__i__
#rss-show-summary-2
#rss-show-summary-__i__
#rss-title-2
#rss-title-__i__
#rss-url-2
#rss-url-__i__
#screen-meta
#screen-meta-links
#screen-options-link-wrap
#screen-options-wrap
#screenoptionnonce
#show-settings-link
#tab-link-missing-widgets
#tab-link-overview
#tab-link-removing-reusing
#tab-panel-missing-widgets
#tab-panel-overview
#tab-panel-removing-reusing
#widget-10_recent-posts-__i__
#widget-11_rss-__i__
#widget-12_search-__i__
#widget-13_tag_cloud-__i__
#widget-14_text-__i__
#widget-15_widget_twentyeleven_ephemera-__i__
#widget-16_rss-2
#widget-1_archives-__i__
#widget-2_calendar-__i__
#widget-3_categories-__i__
#widget-4_nav_menu-__i__
#widget-5_links-__i__
#widget-6_meta-__i__
#widget-7_monster-__i__
#widget-8_pages-__i__
#widget-9_recent-comments-__i__
#widget-archives-__i__-count
#widget-archives-__i__-dropdown
#widget-archives-__i__-savewidget
#widget-archives-__i__-title
#widget-calendar-__i__-savewidget
#widget-calendar-__i__-title
#widget-categories-__i__-count
#widget-categories-__i__-dropdown
#widget-categories-__i__-hierarchical
#widget-categories-__i__-savewidget
#widget-categories-__i__-title
#widget-links-__i__-category
#widget-links-__i__-description
#widget-links-__i__-images
#widget-links-__i__-limit
#widget-links-__i__-name
#widget-links-__i__-orderby
#widget-links-__i__-rating
#widget-links-__i__-savewidget
#widget-list
#widget-meta-__i__-savewidget
#widget-meta-__i__-title
#widget-monster-__i__-savewidget
#widget-nav_menu-__i__-nav_menu
#widget-nav_menu-__i__-savewidget
#widget-nav_menu-__i__-title
#widget-pages-__i__-exclude
#widget-pages-__i__-savewidget
#widget-pages-__i__-sortby
#widget-pages-__i__-title
#widget-recent-comments-__i__-number
#widget-recent-comments-__i__-savewidget
#widget-recent-comments-__i__-title
#widget-recent-posts-__i__-number
#widget-recent-posts-__i__-savewidget
#widget-recent-posts-__i__-title
#widget-rss-2-savewidget
#widget-rss-__i__-savewidget
#widget-search-__i__-savewidget
#widget-search-__i__-title
#widget-tag_cloud-__i__-savewidget
#widget-tag_cloud-__i__-taxonomy
#widget-tag_cloud-__i__-title
#widget-text-__i__-filter
#widget-text-__i__-savewidget
#widget-text-__i__-text
#widget-text-__i__-title
#widget-widget_twentyeleven_ephemera-__i__-number
#widget-widget_twentyeleven_ephemera-__i__-savewidget
#widget-widget_twentyeleven_ephemera-__i__-title
#widgets-left
#widgets-right
#wp-admin-bar-a8c_developer
#wp-admin-bar-comments
#wp-admin-bar-debug-bar
#wp-admin-bar-edit-profile
#wp-admin-bar-logout
#wp-admin-bar-my-account
#wp-admin-bar-new-content
#wp-admin-bar-new-content-default
#wp-admin-bar-new-domicile
#wp-admin-bar-new-link
#wp-admin-bar-new-media
#wp-admin-bar-new-page
#wp-admin-bar-new-post
#wp-admin-bar-new-user
#wp-admin-bar-root-default
#wp-admin-bar-site-name
#wp-admin-bar-site-name-default
#wp-admin-bar-top-secondary
#wp-admin-bar-updates
#wp-admin-bar-user-actions
#wp-admin-bar-user-info
#wp-admin-bar-view-site
#wp_inactive_widgets
#wpadminbar
#wpbody
#wpbody-content
#wpcontent
#wpwrap
#zt-debug-bar-cron-css

I collected the IDs with a small plugin that can be used on any page:

<?php # -*- coding: utf-8 -*-
/* Plugin Name: T5 List IDs */
add_action( 'shutdown', function()
{ ?>
<script>
jQuery( function( $ )
{
    var els = []
    $( '[id]' ).each( function() { els.push( this.id ) } )
    els.sort()
    var pre = $( '<pre/>' ).css( 'margin','10px' ).html( '#'+els.join( '<br>#' ) )
    $( document.documentElement ).append( pre )
})
</script><?php
}
);
share|improve this answer
5  
+1 (Edit) Added to Codex register_sidebar(). –  kaiser Jul 28 '12 at 23:34
    
For some reason, widget areas whose id starts with head tends to not render properly on the admin page, at least for me –  Manny Fleurmond Dec 9 '13 at 6:18
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.