WordPress Tutorials Index | Web Page Design Tutorials Home

Study WordPress Sidebar Section File Structure

The file structure of WordPress Sidebar Section (sidebar.php) is also very simple. The codes are very easy to understand and follow since all the codes are commented very well. I noticed that the Sidebar seems to be a place to embed the Widgets. Interesting enough, the widget areas are divided into two sections – the primary widget area and the secondary widget area.

WordPress Sidebar File Structure

Let’s take a look what widgets are already put on the Widget Area. Widgets can be managed in the WordPress Admin Panel at Dashboard -> Appearance -> Widgets as shown in the diagram below:

WordPress Sidebar File Structure

Take a look at what widgets are already put on the Widget Area. There are already 6 widgets put on the Primary Widget Area by default when WordPress was installed.

WordPress Sidebar File Structure

However there is no any widget put on the Secondary Widget Area. Let’s put on a widget (Calendar) to the Secondary Widget Area to see how it will be displayed. As expected the Calendar display immediately below the Primary Widget Area. In other words, the Secondary Widget Area is just below the Primary Secondary Area.

WordPress Sidebar File Structure

Another interesting thing we found out is that the WordPress programmer do not wish the Sidebar Area appear to be blank when there is no any widget put on it. Take a look at the codes:

WordPress Sidebar File Structure

Note that if there is no any widget on the Primary Widget Area, the hard-code widgets will be used. Therefore the Primary Widget Area will never be empty.

We will shows how to write codes for widgets to insert into Sidebar and other sections later. Please read on.....