Register_sidebar () (Create sidebar)
Create a sidebar for placing gadgets. When this function is used, 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 create.
Default value:
$args = Array (
' name ' => __ (' Sidebar name ', ' Theme_text_domain '),
' id ' => ' Unique-sidebar-id ',
' description ' => ', '
class ' => ',
' before_widget ' => ' <li ', id= '%1 ' class= ' Widget%2 ">",
' after_widget ' => ' </li> ',
' before_title ' => '
Introduction to Array Parameters:
- Name: Side-side bar names
- ID: Side bar ID, must be lowercase, default to incremented array ID
- Description: Side Sidebar description
- Class: Extra Class for gadgets
- Before_widget: The beginning of the gadget inside the Html code
- After_widget: The Html code at the end of the gadget inside
- Before_title: The opening Html code of the title of the gadget inside
- After_title: The Html code at the end of the title of the gadget inside
Example
Register_sidebar (
' name ' => __ (' Sidebar on right side '),
' id ' => ' sidebar-1 ',
' description ' = > (' Small tool on the right sidebar. '),
' before_title ' => '
Other
This function is located at: wp-includes/widgets.php
Get_sidebar () (Get side bar)
Get_sidebar () is used to introduce sidebar templates. If the specified name introduces the sidebar-{name}.php file of the current topic root, does not specify a sidebar.php file that introduces the root of the current topic, or if the file does not exist, introduces the wp-includes/theme-compat/ sidebar.php files.
Usage
Parameters
$name
(optionally) to introduce the name of the template, if specified, to introduce the sidebar-{$name}.php file of the current topic root.
Default value: None
Example
The code below will introduce the sidebar.php file for the current topic root:
The code below will introduce the sidebar-left.php file for the current topic root:
<?php Get_sidebar (' left ');?>
The example below introduces the left sidebar (sidebar-left.php) and the right-hand sidebar (sidebar-right.php):
<?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