Step 2: Creating the sidebars.php
*** IMPORTANT! IMPORTANT! IMPORTANT! ***
Understand this. It’s the key to grasping what the heck is going on in the whole process. Days of long hours were spent getting this simple fact into my head. The realization was like a Kleig light switching on a foot from my face.
Sidebars and sidebars.php are NOT the same thing.
Got it? “So what?” you might ask. To make it clearer to us, let’s think of any sidebar.php as a CONTAINER holding various sidebars.
To see the difference, we’ll make a new sidebar.php. Use a text editor like Notepad (do NOT use Word!) to create the file. Leave it empty. Save As sidebar-double.php. The type will remain “Text Documents (*.txt), but so long as the name itself ends in “.php” the file will save at a php type. Now upload it via an FTP program like Filezilla or you can use the File Manager tool in your Hosts C-Panel.
Back into the WordPress editor, you will now see the new template we just created. Open it. Here is where you will understand the nitty-gritty of the sidebar-creation process. Copy and paste the following into the empty sidebar-right.php:
Sidebar-double.php Code
<ul id="sidebar" class="leftthin">
<?php if ( !function_exists('dynamic_sidebar')
|| !dynamic_sidebar('LeftThinSB') ) : ?>
<?php endif; ?>
</ul>
<ul id="sidebar" class="rightthin">
<?php if ( !function_exists('dynamic_sidebar')
|| !dynamic_sidebar('RightThinSB') ) : ?>
<?php endif; ?>
</ul>
The nugget of significance (I like that phrase!) is in the third line in each. We are using the two sidebars named
‘RightThinSB’
that we just registered in functions.php. When we added the code lines ‘name’=>’LeftThinSB’ and ‘name’=>’RightThinSB’, that gave us new sidebars to use.
All this must be confusing. It certainly was to me. A diagram will help.
What is imperative that you see from Diagram 1 is this: sidebar.php files are simply containers . These containers are “delivered” to various other template files, primarily Page and Post templates, and, if desired, the Front Page. The “entry point” for these containers is the get_sidebar() code in those template files.
The sidebar-double.php code says, “The container called sidebar-double.php will use the registered sidebars named ‘LeftThinSB’ and ‘RightThinSB’.
The sidebar.php “container” will “hold” whatever registered sidebars we place in it.