sidebar.php
Fallback sidebar template for themes that do not provide their own.
Source: wp-includes/theme-compat/sidebar.php
Deprecated: 3.0.0
Subpackage: Theme_Compat
Purpose
Loaded by get_sidebar() when the active theme has no sidebar.php. Outputs a widgetized sidebar with contextual archive information and navigation.
Behavior
Calls
_deprecated_file()— deprecation notice.Opens
<div id="sidebar" role="complementary">with a<ul>.Dynamic sidebar check: Calls
dynamic_sidebar()— if the function doesn’t exist or returns false (no widgets assigned), outputs the static fallback content below.Static fallback content (inside the
ifblock):a. Search form via
get_search_form().b. Commented-out Author section — HTML comment suggesting an author bio block.
c. Contextual archive messages — checks page type and outputs a descriptive paragraph:
is_404()— no message (empty block)is_category()— "You are currently browsing the archives for the {category} category." viasingle_cat_title()is_day()— "You are currently browsing the {site} blog archives for the day {date}." Date formatted with__( 'l, F jS, Y' )is_month()— "…archives for {month}." Date formatted with__( 'F, Y' )is_year()— "…archives for the year {year}." viaget_the_time( 'Y' )is_search()— "You have searched the {site} blog archives for ‘{query}’." viaget_search_query()is_paged()(via$_GET['paged']) — "You are currently browsing the {site} blog archives."
Navigation
<ul role="navigation">:- Pages via
wp_list_pages()with title "Pages" - Archives (monthly) via
wp_get_archives( array( 'type' => 'monthly' ) ) - Categories via
wp_list_categories()withshow_count => 1
- Pages via
Home/Page-specific content (when
is_home()oris_page()):- Bookmarks via
wp_list_bookmarks()
- Bookmarks via
Closes the sidebar divs.
Functions Called
| Function | Purpose |
|---|---|
_deprecated_file() | Deprecation notice |
__(), _e() | Translation |
sprintf(), basename() | String formatting |
dynamic_sidebar() | Attempt to render widgets |
get_search_form() | Search form |
is_404(), is_category(), is_day(), is_month(), is_year(), is_search(), is_paged(), is_home(), is_page(), is_single() | Conditional tags |
single_cat_title() | Current category name |
get_bloginfo() | Site name and URL |
get_the_time() | Formatted date |
get_search_query() | Current search query |
esc_html() | Escape search query for display |
wp_list_pages() | List pages |
wp_get_archives() | Monthly archive list |
wp_list_categories() | Category list with counts |
wp_list_bookmarks() | Blogroll/links |
wp_register() | Registration/admin link |
wp_loginout() | Login/logout link |
wp_meta() | Sidebar meta hook |
Variables Referenced
| Variable | Purpose |
|---|---|
$_GET['paged'] | Checked directly (not sanitized) to detect paginated views |