The WordPress Twenty Fifteen Sidebar and Footer Templates - dummies

The WordPress Twenty Fifteen Sidebar and Footer Templates

By Lisa Sabin-Wilson

Creating themes for your WordPress site requires you to step into the code of the templates, including the sidebar and footer templates, which can be a scary place sometimes. Get started by understanding the structure of some of the templates.

The Sidebar template

The Sidebar template in WordPress has the filename sidebar.php. The sidebar is usually found on the left or right side of the main content area of your WordPress theme. (In the Twenty Fifteen theme, the sidebar is on the left of the main content area.) The sidebar is a good place to put useful information about your site, such as a site summary, advertisements, or testimonials.

Many themes use widget areas in the Sidebar template. This allows you to display content easily on your WordPress pages and posts. The Sidebar template is called into the Header template, which is called into the Main Index template. The Sidebar template gets called in using this template tag (as seen in header.php in the Twenty Fifteen theme):

<?php get_sidebar(); ?>

This code calls the Sidebar template and all the information it contains into your site.

The Footer template

The Footer template in WordPress has the filename footer.php. The footer is generally at the bottom of the page and contains brief reference information about the site. This usually includes copyright information, template design credits, and a mention of WordPress. Similar to the Header and Sidebar templates, the Footer template gets called into the Main Index template through this bit of code:

<?php get_footer(); ?>

This code calls the Footer template and all the information it contains into your site.

The default Twenty Fifteen theme shows a statement that says Proudly powered by WordPress. You can use the footer to include all sorts of information about your site, however; you don’t have to restrict it to small bits of information.

You can write calls for the Sidebar and Footer templates that are written as part of a larger call and are written like this:

<?php
get_sidebar();
get_footer();
?>

It is possible, and common, to wrap two template tags in one PHP function like that, if they appear directly after one another.

There is one line of code that should exist in every Footer template for any WordPress theme: <?php wp_footer(); ?>. This tag serves as a hook in WordPress that plugin developers use to insert necessary code and functions. Without this tag, the majority of plugins for WordPress will not function correctly, so be sure your Footer template includes the tag <?php wp_footer(); ?> before the closing </html> HTML markup.