Step 4: Making Entry Points in Pages and Posts
The last step is the easiest and in a sense the most powerful. Remember that get_sidebar() calls the default sidebar. To call a specific sidebar, all that’s needed is to tell that function which sidebar to get. If you look at the Front Page, only one sidebar is visible, as you haven’t told the home Page or any others to use the sidebar-double.php template.
Recall my club to the head note above? That Sidebars and sidebars.php are NOT the same thing? Well here is where that simple bit of knowledge pays off and the point at which I finally got it!
What you call within the parentheses in get_sidebar() is NOT the name of the sidebar, but the name of the php file. Thus, we are calling a container of sidebars. In our case, the container sidebar-double.php which contains the registered sidebars named ‘LeftThinSB’ and ‘RightWideSB’.
The format of this call uses the name of the php file, not the larger link name in blue above it: (In this case, they are the same)
Another important point here, a naming convention. If you wondered why we used “sidebar-double” rather than simply “double” or “doublesidebar,” WordPress recognizes what follows the “sidebar-” as the name of the file. Use this convention for custom Page and Post names as well. So, we can simply use “double” as the name of this php container in get_sidebar(‘double’), and WordPress knows we mean sidebar-double.php. Yes, leave off the .php extention. And, Yes, put the name in single quotes.
Now, let’s go to Page.php and change it. At the top of the Page.php file is this (after we added our get_sidebar toward the beginning of this tutorial:
Into those parentheses following get_sidebar we enter our sidebar-double.php name, which is: ‘double’.
It now reads: <?php get_sidebar(‘double’); ?>
Update the Page.php file and take a look at the Front Page.
We have the ‘LeftThinSB’ sidebar floated to the left and the ‘RightThinSB’ sidebar floated to the right. Of course there’s nothing in the right sidebar because we haven’t added any widgets. Let’s add some dummy text to get the real picture. I’ve just added a couple text widgets.
Well, those are the basics as I can understand them. I sincerely hope my explanations help you understand the mechanics of this tricky area. And,if you’re feeling brave, the next tutorial covers adding double sidebars to one side and adding one or more to the top and bottom of a page.