Email This Post
I’ve had a few people asking how they can add a second column sidebar to a one column wordpress theme. To do this you will need to edit the template files index.php, archive.php, page.php and single.php.
Here is the code with step by step instructions. Before you begin you will need to decide where you want the sidebar.
- Login to your Wordpress administration panel
- Select Presentation ->Theme Editor from the navigation menu
- On the Theme Editor page, you will see a list of â€śtheme filesâ€ť to the right of the page. Select the â€śmain index templateâ€ť (index.php).
- Copy and paste the following code before the last </div> of the <div id=”primaryContent”> and before <?php get_footer(); ?>. This will ensure the sidebar appears above the footer.
<?php get_sidebar(); ?>
- Still on the Theme Editor page, select the â€śsidebar templateâ€ť (sidebar.php).
- Add the following code after the last </div> of the left or right sidebar
- <div class=”right-sidebar”>
- Now open the style sheet (style.css) and style it up how you want it to match the theme. For example
The best thing to do is to see how your other sidebar is styled and copy that code just changing the left or right wording.
You can view your site now and you should be able to see the new sidebar added to your main home page. You need to now repeat the above steps 1-Â 5 on the following template files:
archive.php - this will show the sidebar on all your category pages
page.php - this will show the sidebar on all your pages you create in Wordpress
single.php - this will show the sidebar on every single post
Thatâ€™s it your done! Feel free to comment if you have any questions.