Register_sidebar () (Create sidebar)
Create a sidebar that you can use to place small tools. When this function is used, please put it in a function and mount it to the "widgets_init" hook.
Usage
Register_sidebar ($args);
Parameters
$args
(String | Array) (optional) The parameters of the sidebar to be created.
Default value:
$args = Array ( ' name ' = + __ (' Sidebar name ', ' Theme_text_domain '), ' id ' = ' Unique-sidebar-id ', ' description ' + ' , ' class ' = ' ' , ' before_widget ' = '
', ' after_widget ' = '', ' before_title ' = '
', ' after_title ' = '
');
Array parameter Description:
- Name: Side bar Names
- ID: Side bar ID, must be lowercase, increment array ID by default
- Description: Side Bar Description
- Class: An extra class to the gadget
- Before_widget: The opening of the gadget inside the Html code
- After_widget: Html code at the end of the gadget inside
- Before_title: Html code at the beginning of the title of the gadget inside
- After_title: Html code at the end of the title of the gadget inside
Example
Register_sidebar ( ' name ' = ' = ' right side sidebar '), ' id ' = ' sidebar-1 ', ' description ' = > __ (' Widgets on the right sidebar. '), ' before_title ' = '', ' after_title ' = '
',));
Other
The function is located at: wp-includes/widgets.php
Get_sidebar () (Get sidebar)
Get_sidebar () is used to introduce sidebar templates. If the specified name is introduced into the sidebar-{name}.php file of the current topic root, the sidebar.php file that introduces the root of the current theme is not specified and is introduced if the file does not exist wp-includes/theme-compat/ sidebar.php file.
Usage
Get_sidebar ($name);
Parameters
$name
(string) (optional) introduces the name of the template and, if specified, the sidebar-{$name}.php file that introduces the root of the current theme.
Default value: None
Example
The following code introduces the sidebar.php file to the root of the current theme:
<?php Get_sidebar ();?>
The following code introduces the sidebar-left.php file to the root of the current theme:
<?php Get_sidebar (' left ');?>
The following example introduces the left sidebar (sidebar-left.php) and the right sidebar (sidebar-right.php), respectively:
<?php Get_header ();? ><?php Get_sidebar (' left ');?>
Content content
<?php Get_sidebar (' right ');? ><?php Get_footer ();?>
Other
This function is located at: wp-includes/general-template.php
The above describes the WordPress used to create and get sidebar in the PHP function explained, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.