How to make WordPress blog add multiple sidebar sidebar

Source: Internet
Author: User
Tags wordpress blog

In the production of WordPress template , perhaps you will encounter a sidebar sidebar does not fully meet your needs, or too much sidebar content causes the page too long, then we can consider using two or more sidebar.

Considering the need to modify the functions.php and sidebar.php files, back up the files before you start just in case.
First look at the functions.php file. The beginning of a piece of code in the file is this:

if function_exists (' Register_sidebar '))

Delete the code and the corresponding closing parenthesis, and then add the following:

if function_exists (' Register_sidebar ')) Register_sidebar (array(' name ' = ' sidebar1 ', ' before_widget ' = ' ", ' After_widget ' + ', ' before_title ' = ' ; >

This is a sidebar of the corresponding code, if we want to be two sidebar effect, then add a section of the sidebar code, into:

if function_exists (' Register_sidebar ')) Register_sidebar (array(' name ' = ' sidebar1 ', ' before_widget ' = ' ", ' After_widget ' + ', ' before_title ' = ' ; Register_sidebar (  Array(' name ' = ' sidebar2 ', ' before_widget ' = ' ', ' after_widget ' + ', ' before_title ' = ;? >

If you want to display more than a few sidebar, just copy the same code snippet, and then change the number behind the SIDEBAR1/2.
After registering the necessary sidebar, there are three widget boxes in Wp-admin's Wiget, and then we need to activate the sidebar so it can be displayed at the front of the blog.
After you open the sidebar.php file, you will see a line of code like this:

if ( ! function_exists endif;?>

Delete it, then add:

if ( ! function_exists endif;?>

The above code makes SIDEBAR1 appear in the front of the blog. To display both SIDEBAR1 and SIDEBAR2, join:

if ( ! function_exists endif if ( ! function_exists endif;?>

And so on, to display sidebar345, add the same code and change the numbers slightly.
Done.
Note: When modifying the functions.php file, be careful to remove extra closing brackets or spaces.

How to make WordPress blog add multiple sidebar sidebar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.