How wordpress adds a sidebar to an article page

When making wordpress templates, one sidebar may not fully meet the requirements, or the sidebar content is too long. You can consider using two or more sidebars.

Considering the need to modify the files in functions.PHP and sidebar.php, please back up the files before starting, just in case.

Step 1: First look at the functions.php document. There is a piece of code in the file that starts like this:

Step 2: Delete this code and the corresponding closing bracket, and then add the following:

Step 3: This is the corresponding code of a sidebar. If you want two sidebar effects, add a sidebar code as follows:

If you want to display more sidebar, just copy the same code segment and change the number after sidebar 1/2.

After registering the necessary sidebar, there are three wiki boxes in wp-admin's wiki, and then you need to activate the sidebar so that it can be displayed in front of the blog.

Step 4: After opening the sidebar.php file, you will see a line like this:

Step 5: Delete it and add:

Step 6: The above code makes sidebar 1 displayed at the front end of the blog. To display both Sidebar 1 and Sidebar 2, add:

By analogy, to display sidebar345, please add the same code and change the number slightly.

Note: When modifying the functions.php file, please pay attention to delete the redundant right brackets or spaces.