The PHP function used to create and get sidebar in WordPress is explained, wordpressphp
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
Articles you may be interested in:
- Tips for customizing the background Management interface color scheme in WordPress
- Implementation of correlation function parsing for sending HTTP requests in WordPress
- Ways to set default content in the WordPress article editor
- How to use the function of adding and executing actions in WordPress
http://www.bkjia.com/PHPjc/1086653.html www.bkjia.com true http://www.bkjia.com/PHPjc/1086653.html techarticle PHP functions for creating and getting sidebar in WordPress, wordpressphp Register_sidebar () (Create sidebar) creates a sidebar for placing gadgets. This function makes ...