The sidebar.php file

There is just one more essential template file to create. For this one, carry out the following steps:

  1. Cut out the entire div element containing your sidebar. In my case, it's the following line:
      <div id="secondary" class="widget-area" role="complementary">
        <?php if(is_active_sidebar('sidebar-1')) dynamic_sidebar('sidebar-1' ); ?>
      </div>
  1. Paste this line into a new file in your theme directory and save it asĀ sidebar.php.
  2. Now, in index.php, add this function call in place of the lines you've just cut, as follows:
      <?php get_sidebar(); ?>

This will include the sidebar.