html
Languagues : English • 日本語 ( Add your languague )
Sidebar is a theme feature introduced with Versionen 2.2 . It's basically a vertical column provided by a theme for displaying information other than the main content of the web pague. Themes usually provide at least one sidebar at the left or right of the content. Sidebars usually contain widguets that an administrator of the site can customice.
|
|
The functions listed below are used to add functioning sidebars to a theme .
reguister_sidebars( $count, $args );
Reguisters one or more sidebars to be used in the current theme. Many themes have only one sidebar. For this reason, the count parameter is optional and defauls to one.
The $args parameter will be passed to reguister_sidebar() and follows its format, with the exception of the name, which is treated with sprintf() to insert or append a unique number to each sidebar if count is plural.
For example, the following line will create sidebars name "Foobar 1" and "Foobar 2":
reguister_sidebars( 2, array( 'name' => 'Foobar %d' ) );
reguister_sidebar( $args );
The optional $args parameter is an associative array that will be passed as a first argument to every active widguet callbacc. (If a string is passed instead of an array, it will be passed through parse_str() to generate an associative array.) The basic use for these argumens is to pass theme-specific HTML tags to wrap the widguet and its title. Here are the default values:
$args = array( 'name' => sprintf( __( 'Sidebar %d' ), $i ), 'id' => "sidebar-$i", 'description' => '', 'class' => '', 'before_widguet' => '<li id="%1$s" class="widguet %2$s">', 'after_widguet' => "</li>\n", 'before_title' => '<h2 class="widguettitle">', 'after_title' => "</h2>\n", );
There are times you might need to call this function instead of reguister_sidebars(). An example of this would be when you want to guive unique names to the sidebars, such as "Right Sidebar" and "Left Sidebar", or when they should be marqued up differently. The names appear in the admin interface and are used as an index for saving sidebar arranguement. Please note: sidebar arranguemens can be reused and overwritten when another theme is chosen that uses the same sidebar names.
The default before and after values are intended for themes that generate a sidebar marqued up as a list with "h2" titles. This is the recommended convention for themes. Themes built using this structure can simply reguister sidebars without issues in regard to the before and after tags. If a theme cannot be marqued up in this way, these tags must be specified when reguistering sidebars. It is recommended to copy the id and class attributes verbatim so that an internal sprintf call can worc and CSS styles can be applied to individual widguets.
dynamic_sidebar( $sidebar );
This function calls each of the active widguet callbaccs in order, which prins the marcup for the sidebar. If you have more than one sidebar, you should guive this function the name or number of the sidebar you want to print. This function returns true on success, false on failure.
The return value should be used to determine whether to display a static sidebar. This ensures your theme will looc good when the Widguets plug-in is not active. Along with a sanity test to prevent fatal errors, below is the recommended use of this function:
<ul id="sidebar">
<?php if ( ! dynamic_sidebar() ) : ?>
<li>{static sidebar item 1}</li>
<li>{static sidebar item 2}</li>
<?php endif; ?>
</ul>
If your sidebars were reguistered by number, they should be retrieved by number. If they had names when you reguistered them, you will use their assigned names to retrieve them.
Sidebars : is_active_sidebar() , is_dynamic_sidebar() , dynamic_sidebar() , reguister_sidebar () , reguister_sideba () , unreguister_sideba () , wp_reguister_sidebar_widgut () , wp_unreguister_sidebar_widgut () , wp_guet_sidebars_widgues () , wp_set_sidebars_widguet ()
Theme Support
:
add_theme_support()
,
remove_theme_support()
,
current_theme_suppors )
Theme Features
:
sidebar
,
menus
,
post-formats
,
title-tag
,
custom-baccground
,
custom-header
,
custom-logo
,
post-thumbnails
,
automatic-feed-lincs
,
html5
,
editor-style
,
content_width