• Austin SEO
    • TastyPlacement in the Press
    • Meet the Team
  • Blog
  • Services
    • SEO Services
      • WordPress SEO Service
      • Magento SEO Services
      • Conversion Rate Optimization
      • SEO Audit Service
      • Why Google Certification Matters
    • PPC & Adwords
      • Adwords & PPC Management
      • Remarketing Services
      • Display Ad Management
      • Facebook Ad Management
      • Google Ad Grants Management for Non-Profits
      • Adwords App Install Ad Management
      • Product Listing Ad Management
    • Analytics & Data
      • Analytics and Monitoring
      • Google Tag Manager Experts
      • Data Studio Development & Consulting
    • Social Media & Local Marketing
      • Social Media Marketing
      • Local SEO
    • Web Development
      • Mobile Website Design
      • WordPress Development
  • Case Studies
    • SEO Case Studies
      • SEO Case Study: We Beat Lowes, Then We Beat Home Depot
      • SEO Case Study: Total Domination in Houston for Medical Provider
    • Analytics Case Studies
      • Case Study: Updated Design Yields 43% Increase in Conversion Rate
      • Case Study: PPC Optimization Yields Tripled Conversion Rate
    • Social Media Case Studies
      • Social Media Case Study: Hundreds of New Customers From Core Facebook Campaign
  • Portfolios
    • Display Ad Portfolio
    • Design Portfolio
    • Infographic Portfolio
    • SEO Testimonials
  • Contact
    • New Customers: Get to Know Us
    • Customer Service & Support
    • Referral Program
    • SEO Training Seminars
    • Job: Paid Search/PPC/Adwords Analyst
    • Job: Local Digital Marketing Specialist
    • Job: SEO/Marketing Junior Analyst
    • Privacy Policy & Terms of Use
  • Menu Menu

How to Add a Sidebar to Your WordPress Theme

November 19, 2011/121 Comments/in WordPress/by Michael David

Most simple WordPress templates/themes generally employ a single sidebar. But, in keeping with WordPress’ open architecture, you can easily add a second (or 3rd or 4th) sidebar to your site’s theme. And, you aren’t restricted to using your sidebar in the typical sidebar area–you can put your new sidebar in a header, a footer, or any other area in your template. Additional sidebars let you place any WordPress Widget (such as Recent Posts, Pages, Links/Blogroll, Calendar, Tag Cloud, as well as any custom widgets) into new areas of your WordPress template. This technique is especially powerful when combined with custom WordPress page templates–with additional sidebars, we can have custom sidebars for each of our custom page templates. This is the approach we’ll teach you in this tutorial.

Laying the Groundwork for Your New Sidebar

So what we’ll do in this tutorial is to add a second sidebar to one of our custom template pages in our WordPress theme. We have a custom homepage in our template where we want to include a robust call to action to our website visitors rather than a Category list which is more appropriate for blog readers. The screenshot below shows the default “Sidebar 1” sidebar from our simple template, and we’ll add a second sidebar called “Homepage Sidebar”.

Add WordPress Sidebars

Let’s first take a 10,000 foot view, we are going to employ the following steps to add our sidebar:

  • We are going to register our sidebar within the template by making an entry in the template’s functions.php file.
  • We are going to create a separate, custom sidebar file called sidebar-homepage.php.
  • We are going to include a reference to our custom sidebar-homepage.php file in our custom page template.

That’s it! With these three steps, we’ll have a 2nd sidebar that will display on our custom homepage. With the same technique, we could create additional sidebar areas, the steps would be the same.

Step 1: Registering the Additional Sidebar Within the WordPress Template

First step: we start by registering our sidebar within the template’s functions.php file. 99% of all WordPress templates/themes have a functions.php file. If your theme doesn’t have one, simply create a file in a text editor (we like Notepad++ in the Windows environment and TextMate in the Apple environment). If you don’t know how to find your theme files, you’ll find them in your web host in the following directory: www.yoursite.com/wp-content/themes/yourtheme/.

You’ll want to begin by finding any existing “register_sidebar” entries in your functions.php file. Ours had the following existing sidebar definition for our single default sidebar:

if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
}

To register our second sidebar, we simply add the following code to the functions.php file:

if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Homepage Sidebar',
'id' => 'homepage-sidebar',
'description' => 'Appears as the sidebar on the custom homepage',
'before_widget' => '<div style="height: 280px"></div><li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
}

So what did we just do?

  • We told our WordPress installation, “we are adding a second sidebar area that we’ll use in our theme”
  • The sidebar’s name is “Homepage Sidebar”
  • The ID of the sidebar (we’ll refer to that ID later) is “homepage-sidebar”; you can choose “footer-sidebar”, “second-sidebar” or anything you want
  • We added the description “Appears as the sidebar on the custom homepage” that will display just under the sidebar’s title.

If you upload your new functions.php file to your WordPress installation, you should see your new sidebar if you browse from your WordPress dashboard to Appearance, then Widgets. It should look like the following picture. We’ve already added a Text Widget with the title “Contact Us” to ours, but yours will be empty when you first look at it. But, all we have done is create the sidebar so far; we haven’t yet taken the steps to display the sidebar anywhere in our theme, that will come in the next steps.

Add WordPress Sidebar Step 2

If you see your new sidebar in the Widgets area of your WordPress Dashboard, you are ready to move on to the next step.

Step 2: Create an Additional Sidebar File

WordPress themes use a default file called sidebar.php to display sidebars on pages and posts. But, our goal is to create a second sidebar, we’ll do that with a separate file called sidebar-homepage.php.

Again, we’ll open our text editor and create a file and paste in the following code and insert the ID of your new sidebar within the “dynamic_sidebar()” declaration like so:

<div id="sidebar">
   <ul>
      <?php
      if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('homepage-sidebar') ) :
      endif; ?>
   </ul>
</div>

Now, we have to note that our example sidebar file is highly simplified. Most sidebar files have more code–this extra code displays core navigation in the event the sidebar does not have any widgets installed in it–but for the purposes of this tutorial, we have to simplify it. As an alternative, you can simply copy your sidebar.php file and rename it. Don’t forget to include your sidebar ID within the dynamic_sidebar declaration (shown in red in the code example above)–that sidebar ID tells WordPress which sidebar (which we registered in Step 1) to display.

Step 3: Call the Additional Sidebar from Your Theme Files

We’re almost there. Now, all we need to do is call our new sidebar file, sidebar-homepage.php from our template files–keep in mind that our file name must follow this construct: sidebar-_______.php; we’ll see why in a moment. In our example, we’ll call our sidebar file from a custom template page–but you can call your new sidebar from a footer file, header file, or any theme file that displays on your WordPress site.

The function in WordPress that calls sidebars is get_sidebar(). When get_sidebar() is used with no information within the parenthesis, WordPress grabs the default sidebar.php file. But we want to grab our sidebar-homepage.php file, so we put “homepage” in single quotes within the get_sidebar parentheses. This tells WordPress to grab a file called sidebar-homepage.php . The code we want to insert in our template file is the following:

<?php get_sidebar('homepage'); ?>

What we’ve told WordPress to do is the following: we want to grab a sidebar file, but not the default sidebar, we want a file called sidebar-homepage.php. With this string of code, we’ve successfully grabbed our custom sidebar file.

Our New Sidebar

If you’ve coded your additional sidebar correctly, you can drag Widgets from the WordPress dashboard to your new sidebar and you’ll see the widgets displayed on your WordPress site. Here’s our new sidebar displaying on our homepage, while we display our default sidebar on interior pages and blog posts:

Our New WordPress Sidebar

Other Approaches to Adding Sidebars

Our method is one of many, there are more elegant ways of accomplishing the same result without creating separate template files, but the method outlined here is simple and reliable. Please comment below if you have questions or run into trouble.

Your WordPress site needs SEO. Buy our WordPress SEO book at Amazon. Now in the second edition!

 

Tags: tutorial, Web Design, WordPress, wordpress templates, wordpress themes
Share this entry
  • Share on Facebook
  • Share on Twitter
You might also like
Ultimate WordPress Hacking Recovery Guide
WordPress Tutorial: Display All Posts on a Page
From the Wordpress SEO book Book Excerpt: Creating Keyword-Rich Content
From the Wordpress SEO book SEO Master Class: Choosing a Keyword-Rich Domain Name
Getting Started With WordPress
Setting Up a Stripe.com Single Payment Page for WordPress
121 replies
  1. danny says:
    February 8, 2012 at 9:09 pm

    very helpful tutorial!!! thank you so much

    Reply
    • deconia says:
      November 7, 2012 at 3:21 am

      Michael good work……!!!!!

      Reply
  2. sohbet says:
    February 10, 2012 at 4:32 pm

    Thanks! Didn’t know one could do it that way. :)

    Reply
  3. Massoud Asgharzada says:
    March 19, 2012 at 9:05 am

    It was great tutorial. Thank you so much. But in my website, it shows a dot (.) behind the sidebar. I need to remove that but don’t know how to to that. could you please help to solve it?

    Reply
    • Michael David says:
      March 20, 2012 at 6:38 am

      What is the website? Email it to me at michael[at]tastyplacement.com

      Reply
    • Nitin Reddy Katkam says:
      May 22, 2013 at 3:35 pm

      It is most likely a stray dot that made its way into your code. Take another look and you should find the dot in the haystack :-)

      Reply
  4. hk says:
    April 4, 2012 at 8:03 pm

    hi there,
    this is working if i stick to adding one more sidebar…as soon as i add an array of sidebars (to get more than one in the footer area) I am seeing the widgets in the WP cms widget area, i can add stuff to it, it is also outputting the widgets in the source code, BUT the content within the widgets is missing – it isn’t being output anywhere…Any ideas would be highly appreciated.

    Reply
    • Nitin Reddy Katkam says:
      May 22, 2013 at 3:37 pm

      If the widgets aren’t showing, it is most likely because you didn’t include the call to the function dynamic_sidebar. Using register_sidebar merely tells WordPress that you have a sidebar somewhere in your theme. It is only by calling dynamic_sidebar that WordPress knows where to render the sidebar.

      Reply
  5. Rick A Prentice says:
    May 2, 2012 at 9:17 pm

    From what I understand, this will only take the place of the existing sidebar so you can swop it out on a per page basis. I have a theme with template options: “Full Page”, “Left Sidebar”, “Right Sidebar”. I need to have a “Left and Right” sidebar on the same page. Unless I have misunderstood how this method works, I don’t think it will do that. Or, have I got it wrong?

    Reply
    • Michael David says:
      May 3, 2012 at 6:54 pm

      No, with this method you can add two sidebars to the same page…in your template file, just call both sidebars:

      Reply
    • RA Prentice says:
      May 31, 2012 at 4:49 pm

      Michael,

      I had forgotten I posted here until I was going through my bookmarks.
      Thanks for responding and thanks for providing this tute.
      Anyway, the theme I use is from “mysitemyway.com” (Dejavu). The child theme is “Dejavu-buddypress”.
      Currently it has: Homepage sidebar and Primary sidebar.
      It also has the ability to create custom sidebars that can be selected per page, but when used they take the place of the existing sidebar.

      Do I add the additional .php to my child or parent?
      Which template file will be the best place to add this:

      Also, I’m thinking I will need to create space via css for the additional sidebar I will place on the right before I add the new sidebar? Will the new sidebar be inside the main container or main content?
      I can reduce the width of the main content and leave space to the right for the new sidebar. Is this correct?

      Thanks for your help, really hope this works.
      Rick

      Reply
    • RA Prentice says:
      May 31, 2012 at 4:55 pm

      Do I add the additional .php to my child or parent?
      Which template file will be the best place to add this:

      get sidebar (left)
      get sidebar (right)

      dropped of other post

      Reply
  6. Marvin says:
    May 2, 2012 at 11:04 pm

    Great tutorial but my new sidebar appears disordered in the botton of my site. do i have to do something in the css styles?

    Reply
    • Michael David says:
      May 3, 2012 at 6:55 pm

      Every template is different, so yes, you might need to make some css adjustments. It’s hard for me to say exactly without studying the template. If you are stuck, you can probably call in a coder for a quick job like that for like 20 bucks on Craigslist or even Elance.

      Reply
  7. sonali says:
    May 29, 2012 at 3:45 am

    It’s helped me lot… thank you so much…… :)

    Reply
  8. Rick A Prentice says:
    May 31, 2012 at 6:45 am

    Michael,
    Thanks for responding. I forgot I had posted here until I was looking at my bookmarks.
    Anyway, My theme (mysitemyway.com… Dejavu) has a homepage sidebar and a primary sidebar. I can also create custom sidebars on a page by page basis but they take the place of existing sidebars. My child theme is Dejavu-buddypress and that is where I want to add the second sidebar on the right side in the buddypress section of my site. Will I add the additional code to the “child” .php or the parent?
    Also, do I need to create space on the right in my css to make room for the sidebar before I add the additional code?
    Thanks for providing this tutorial
    Rick

    Reply
  9. mahmud says:
    June 8, 2012 at 11:48 am

    actually i searched here and there for a way out to create a sidebar just beneath the category nav of my theme. your article gave me the basic idea and i did it on my own accord. thanks to pave me the path.

    Reply
  10. gebelik says:
    June 26, 2012 at 7:38 pm

    if i dont have in my template how can i add foter.php ?

    Reply
  11. Pam Warden says:
    July 16, 2012 at 1:57 pm

    Hi
    I’m not sure how I add things to my sidebar? I can’t find the area to post in. It was easy to see in blogger, but I’m just learning my way around wp and it is quite different in many ways…most of them in GOOD ways.
    Thank you,
    Pam

    Reply
    • Pam Warden says:
      July 16, 2012 at 1:59 pm

      Sorry, in reading back I don’t think I was clear on something, when I said I’m not sure where to post I was still talking about my sidebar.
      Pam

      Reply
  12. Robert says:
    July 23, 2012 at 7:13 am

    Thanks for this badass tutorial! Incredible walk through and I love your “10,000 foot view.” It really helped add four ‘sidebars’ into my footer area.

    Reply
  13. Rehman says:
    July 30, 2012 at 6:06 am

    Nice tutorial!

    Reply
  14. Ken says:
    August 25, 2012 at 8:02 am

    This is absolutely one of the best clearly stated tutorials I’ve come across, except for one issue…and maybe I just don’t get it…

    Appearance==>Editor ==> list of templates on right of page. I see all the templates listed on the right including sidebar.php. Exactly how do I find the folder in which sidebar.php file exists. That is, where do I actually re-create and rename the second (re-named) php file.
    Thanks in advance!

    Reply
    • Ken says:
      August 25, 2012 at 1:04 pm

      Am I correct in the answer to my own question is: Go to CPanel??? wp-content??
      Thx

      Reply
    • Michael David says:
      August 26, 2012 at 7:36 am

      Your template files are found here: yoursite.com/wp-content/themes/YOURTHEME/sidebar.php….for example, our theme stylesheet is in the template folder here: https://tastyplacement.com/wp-content/themes/tastykita-child/style.css

      Reply
      • winresh@4 says:
        July 11, 2013 at 4:27 am

        Hi,Michael

        I just want to ask why is my sidebar is not in the side rather its in the center?
        can you give me a solution in this?
        plsss

        Thank you in advance.

  15. mehdi says:
    September 4, 2012 at 10:39 am

    i want to add a extra sidebar on the left i have just one on the right how i can do that

    Reply
    • Michael David says:
      September 20, 2012 at 10:21 am

      That’s a bit more work because you need to create a css-based

      area in which to house the new sidebar–and then integrate that new area in to the theme’s architecture. That is pretty advanced–we’ll consider writing a tutorial on that in the future.
      Reply
      • Porshia says:
        May 25, 2013 at 1:59 am

        Hi.. have you written a tutorial for a left sidebar? I really need it..
        Thanks for this post though..

  16. Willi says:
    September 13, 2012 at 8:17 pm

    Well written tutorial. That helped a bunch. Very generous friendo!
    My peeps live in Fredericksburg… if I gen up some Hill Country clients, I’ll point them to ya!

    Reply
  17. Madeline says:
    September 14, 2012 at 6:32 pm

    Great tutorial! Is there a way to add a sidebar to a one column theme?

    Reply
    • Michael David says:
      September 20, 2012 at 10:20 am

      Wise guy answer: replace the theme. Well, that’s quite a bit of surgery, I think before I did that I would consider upgrading the template to a shiny new one, seriously.

      Reply
  18. Kwadwo says:
    October 7, 2012 at 1:27 pm

    Awesome tutorial… i love it… how do i call this sidebar so it only appears on a certain category and not the homepage? Thanks … Great post

    Reply
    • Michael David says:
      October 16, 2012 at 5:19 pm

      That’s more complicated and you need to use a plug called “Custom Post Template” which you can find on WordPress.org.

      Reply
  19. dave says:
    October 12, 2012 at 9:19 am

    Brilliant tutorial that’s absolutely saved the day

    Reply
  20. Courtney says:
    October 31, 2012 at 10:15 am

    Ah, but what about for a child theme? I think there’s a lot more involved, am I right? In order to add a sidebar, I have to unregister the parent themes? Can you help me out?

    Reply
  21. Courtney says:
    October 31, 2012 at 11:18 am

    Not to worry, I found the solution!

    Reply
    • mzer michael says:
      February 6, 2013 at 4:44 pm

      Hi, Courtney,

      How did you do that on the child theme??

      Would appreciate if you share.

      Thanks.

      Reply
    • EP says:
      June 23, 2013 at 3:54 pm

      What was the solution?

      Reply
  22. manoj says:
    November 5, 2012 at 12:19 pm

    After trying several tuts i ended up here, thanks a lot bud..

    Reply
  23. cat says:
    November 9, 2012 at 3:16 pm

    Such a great tut, thank you so much!

    Mine worked nearly perfectly… apart from the final step, getting the sidebar to show up!

    My site: http://catillest.com/shop/bear-style-t-shirt/ The standard sidebar is still showing, even though this page is set to product template and the product-sidebar is called within that… I’m not sure what I’m missing.

    any ideas anyone? Any help massively appreciated!

    Reply
    • cat says:
      November 9, 2012 at 3:20 pm

      Agh! Scrap that, all in the naming ‘sidebar-xxxx.php’

      Reply
  24. Alberto Suárez says:
    November 19, 2012 at 1:42 pm

    Thank you very much for your great tutorial !

    Reply
  25. saif says:
    November 23, 2012 at 1:00 am

    Thnx sir
    I realy like it

    Reply
  26. Louie Garofalo says:
    November 25, 2012 at 1:21 pm

    Thanks for writing this up. Very helpful when I had to do some wordpress template building on the fly.

    Reply
  27. Denis says:
    December 10, 2012 at 5:21 pm

    Hello, I’d need help, how to add another sidebar in the theme OpenDoor. I need another sidebar to the right. This theme http://themeforest.net/item/opendoor-responsive-real-estate-and-car-dealership/full_screen_preview/3417587

    Reply
  28. Colin says:
    December 15, 2012 at 3:23 pm

    Hi all,
    Going crazy here trying to get a sidebar to show up.
    I created a custom page template to have a blog page and modified the home page to stop posts showing up. Thats all working nicely.

    I want to have the blog categories show on the blog page so was planning to put the categories widget on a sidebar created using widgets on pages plugin. Completed the steps for that but no sidebar. Completed the steps here and no sidebar. I dont have the layout options available when creating a page and cant figure out why, is this because of the theme im using?

    I tried using another plugin Page Columnist to create columns but still no sidebar

    Reply
    • Nicole says:
      February 5, 2013 at 8:42 pm

      I am having the same issue. Or maybe not. I am not sure where I should call the function. I am using template intrepidity. I see the php file in my template and the widget on my widget page, but when i try passing info into it it does not show. Ideally would like the sidebar to show up in the header of the page.

      Reply
      • Nicole says:
        February 5, 2013 at 9:06 pm

        Actually I found it. I was within the content section of my page. How do i make it align to the left as a left sidebar, or a header side bar?

    • mzer michael says:
      February 6, 2013 at 6:53 pm

      hi Colin why not switch themes and see if that is the issue?

      Reply
  29. SaveMarriage says:
    December 24, 2012 at 9:54 am

    Hello Michael,

    My issue is somewhat different but I was hoping something could help me fix a right sidebar issue. I have a blog at internetmarketerdotcom(DOT)com/blog. When doing a search on my blog using the search bar the right sidebar moves upward from the slider image where it’s suppose to be. This issue only occurs when creating a static home with blog (posts page). I’m using the Woo Headlines Enhanced 3.2.3 theme.

    Before I noticed this issue, another issue had occurred after creating the static home page. The right sidebar moved down to the right of the post content and not the along side the slider where it is now. If fixed this issue issue in my sidebar.php by…

    Replacing this code…

    with this code…

    It worked and my right sidebar now aligned correctly. However the issue I explained earlier still exist. Do a search on my blog and you will see that the right sidebar has moved up.

    Doesn’t anyone know how I can fix this?

    Thanks in advance.

    P.S. The theme I mentioned earliest came with a set of PLR blog that purchased sometime ago so I/m eligible for any support from http://www.woothemes(DOT)com/

    Reply
  30. Jerome O'Connor says:
    January 1, 2013 at 1:07 pm

    A very concise and well-written tutorial. I hope you do more.

    Reply
  31. euhgene says:
    January 12, 2013 at 4:34 am

    I need help to have left side bar for twenty twelve theme how can i do that

    Reply
  32. euhgene says:
    January 12, 2013 at 4:35 am

    I need help to have left side bar for twenty twelve theme how can i do that.Mail me to leonasinc@gmail.com

    Reply
  33. vonromantiko says:
    January 12, 2013 at 8:27 pm

    Nice post hehehe..

    One question please..

    I’m confused with step 3, where .php do I put the code?

    thanks again nice post hehe

    Reply
  34. Angela Hatchman says:
    January 22, 2013 at 10:52 am

    Thanks, It got me there in very little time, perfect …

    Reply
  35. mzer michael says:
    February 6, 2013 at 6:51 pm

    Hi Michael,
    I want the sidebar to appear only on my static frontpage and not all the site pages.
    The conditional tag: if (is_front_page()) does not seem to be working. Maybe i am not placing it in the right place.

    Could you please advice.

    Thanks.

    Reply
  36. vlado says:
    February 8, 2013 at 7:17 am

    Sorry for the very stupid question, but i’m very novice at coding. I didn’t get the 2nd step. Must I made a new file in my responsive theme directory called sidebar-homepage.php and insert the given code in it, or i must do something else? Currently i have the sidebar in my widget area in WP but i don’t have it displayed in my site. Honestly some time ago it took me a lot of nerves to find out how to completely remove it, and now i need it and i have no idea how i removed it xD.

    Reply
  37. Jill says:
    February 8, 2013 at 12:08 pm

    I followed until step 3. Which file am I editing. You say “template files” but which file exactly am I editing?

    Reply
  38. Adrian says:
    February 8, 2013 at 7:27 pm

    Hi, I am looking to hire a developer to do some minor tweaks to a wordpress site (using wp e-commerce) are you available?

    Thanks

    Reply
  39. Michael Stone says:
    February 9, 2013 at 10:53 am

    Could you help me with Step 3 please? Where do I put “”? Does it go in the file created in Step 2?

    Thanks in Advance!

    Reply
  40. Michael Stone says:
    February 9, 2013 at 10:54 am

    “”

    Reply
  41. Michael Stone says:
    February 9, 2013 at 10:55 am

    <–! –>

    Reply
  42. Gbenga Olotu says:
    February 11, 2013 at 12:39 pm

    Thanks for this post…It was really informative. I’m new to word press. I’ve gone through tutorials on presscoders to get me up and running. I want to customize this template ( http://www.wpexplorer.com/gopress-wordpress-theme/ ) to make it have this look and feel ( http://demo.mythemeshop.com/s/?theme=Glamour ). All I’ve been able to do so far is to add additional side bars. I want to add an additional column to the template…I don’t know how to go by it. a little hint from you might be helpful. Looking forward to reading from you.

    Regards,
    Olotu Gbenga.

    Reply
  43. MANOS says:
    March 4, 2013 at 5:11 pm

    Hi! actually my site has no sidebar at all. so i fixed 1st step. then what i have to do? where i have to put sidebar.php file? inside index.php? or where else? and then?..

    thanks in advance
    manos-greece

    Reply
  44. boardtc says:
    March 11, 2013 at 6:53 am

    Great article, thanks! Similar to Madeline’s question, I want to add a sidebar to a one column theme. I’d prefer not to change the theme – I’ve already hacked it a bit. I can see the sidebar in appearance|widgets as you describe in steps 1 & 2.

    The issue is step 3 and where to call the getsidebar from. Some of my pages (tabs) use custom templates but I want the sidebar to show regardless, like as if the current them was inserted into the first column with the second column being the sidebar. You suggest that it’s not straightforward to do anyway :-(

    Reply
  45. Nerd says:
    March 30, 2013 at 10:36 am

    So when we have sidebars the position in the page is dediced always from php files?…

    Reply
  46. tyee says:
    April 17, 2013 at 1:13 pm

    hi great tutorial but i have this theme that come with no slider and i would like to add slider to the theme. the theme name is magnifique. i have followed your instructions but i dont see any side bars showing up. basaically the questions is how do i add side bar to a theme that has none. not to a theme that has one but none please.
    thank you

    Reply
    • tyee says:
      April 17, 2013 at 1:16 pm

      how do i add it to the right please

      Reply
  47. Sardasht says:
    April 18, 2013 at 9:47 am

    HI Thanks wonderful tutorial

    I was doing all steps you write and I succeed to drag a content to a widget but it doesn’t appear on my template!

    Reply
  48. :) says:
    April 20, 2013 at 1:49 am

    Bingo.. rocking

    Most easy tutorial.. less complex .even to those who dont have php background understand it quick.

    Reply
  49. Shahid says:
    May 7, 2013 at 6:00 am

    A Very well written tutorial, very much helpful to me,
    Regards…..

    Reply
  50. sohbet says:
    May 11, 2013 at 10:19 pm

    very helpful tutorial!!! thank you so much..

    ßye Lee

    Reply
  51. Elina says:
    May 13, 2013 at 9:26 am

    Thanks for this helpful tips. Can you share how to add related posts under each posts.

    Reply
  52. hornlouder says:
    May 15, 2013 at 3:23 am

    Hi, my website dont have any sidebars. Can i still use this method to add sidebars to the left and right hand sidebars?

    Reply
    • atul pareek says:
      January 6, 2018 at 1:12 am

      yes just create a new file, and call it using get_sidebar() mehod in your tamplet

      Reply
  53. dilip wijayabahu says:
    May 24, 2013 at 8:43 am

    thank u so much ….this tutorial is very help to my wp life…. :)

    Reply
  54. Tara says:
    May 30, 2013 at 12:45 pm

    Thanks for the tutorial! I used the information to add an additional sidebar to a client’s website. Their first sidebar has simple company information, the additional one is for their blog!

    Also, LOVE your website design!

    Reply
  55. Mohd ali says:
    June 9, 2013 at 10:51 am

    Great tutorial…..

    Reply
  56. Abhijit Guha says:
    June 12, 2013 at 5:44 am

    hi I want to make a left sidebar in my theme, I have registered the widget area, but I am confused where to add the ” ” ???

    please help

    Reply
  57. Pakinai Kamolpus says:
    June 13, 2013 at 4:03 am

    Thank you very much. This is simple and clear. :)

    Reply
  58. Daniel says:
    June 24, 2013 at 7:03 pm

    Ok I got everything until the #3… It talkes about calling the page, but where are we suppose to save that code? there is no sidebar-homepage.php I dont get it.. Am kind of you but i understand some of it.. Just need clarification on step #3

    Thanks

    Reply
    • Mr Tenerife says:
      August 15, 2013 at 3:55 pm

      Hi Daniel,
      There will be other template pages such as ‘post.php’ / ‘home.php’ / ‘search.php’ in the base of your theme. You enter the content in #3 inside any of those types of template pages to see the new sidebar appear in any page of your site which uses that particular template page such as single post page ‘single.php’ (depending on what theme you have loaded.)

      Reply
  59. winresh24 says:
    July 11, 2013 at 3:24 am

    Hi, Michael

    I just want to know if its going to be the same layout as the Theme?
    Pleases answer back.

    Thank you in advance.

    Reply
    • Naples FL says:
      August 15, 2013 at 4:04 pm

      @winresh24
      Following Michael’s instructions above will use whatever stylesheet is being active within your theme – so yes to your answer. However,/b> – if you add your own custom classes as part of your sidebar you will have to ensure that those class details are added into the stylesheet else you won’t get your desired layout.

      Reply
  60. Syxguns says:
    July 11, 2013 at 5:03 am

    Michael,
    Fantastic tutorial, you don’t know how much searching I did to find this! Now I only hope that I can make it work for me. I may need to PM you with the specifics, but lets just say for the time being that I have a fantastic theme for WP called Bluebirds. Currently I have a redirect script that will not take you there, but if you wish to view it the location is https://www.place4musicians.com/news

    Now the way my template was originally constructed I am suppose to use a plugin called Ad-Minister to accomplish what I need done. Needless to say I’ve had the following difficulty:

    http://wordpress.org/plugins/ad-minister/ has not been updated in over 2 years, it does not work with WP 3.5.2

    I’ve also tried without success Adsense Insertion, and WP Simple Adsense Insertion. I’ve come to the conclusion that relying on others is not something I should do. That is why I’m glad I found your page!

    My objective may be a little more complicated, so I may need some assistance with it. Here is what I did:

    I have sidebar.php file that calls for Ad-Minister, so I commented out those areas. With your code I used “width 125px height 125px” for my Adsense ads. Now there should be 4 of them eventually and I may need a little assistance with that. In the sidebar.php file where the call for Ad-Minister was I placed the which is what I used for my placement.

    Here is the issue; there are a total of 4 ads that I want to place in a square patter in the area that is provided. How do I accomplish this?

    many thanks!

    Reply
  61. Adhityoagam says:
    July 17, 2013 at 8:04 am

    Thank’s Work like SUGDW

    Reply
  62. Betty Jay says:
    August 9, 2013 at 1:02 am

    Thank you very much for the easy to follow tutorial!!! I was able to create my custom sidebars for my different posts and pages in less than 5 minutes – you are awesome! Thank you once again you saved the day :) was looking for this the whole day!

    Reply
  63. Tracy says:
    August 12, 2013 at 10:04 pm

    This was very helpful. My only issue was that I don’t want to use text, I want to use an image in my sidebar that has linkable text (like PSD file) and I can’t get that to render right. Any thoughts? Do I need to create a custom widget?

    Reply
  64. Jens says:
    August 13, 2013 at 3:18 pm

    Thx for this tutorial!

    very clear instructions!

    Reply
  65. swapna says:
    September 1, 2013 at 4:58 am

    I am unable to find the sidebar on my home page….However its displaying in widget area. Kindly help me out.

    Reply
  66. Heidi@OneCreativeMommy says:
    September 6, 2013 at 5:17 pm

    I understand your tutorial perfectly until I get to step three. The only php files in my theme are function.php and home2.php. (Home2.php actually does not get used. It’s for a function in my site that I don’t want. To stop the function and preserve it incase I want it someday, I renamed the file.) Will adding the code to the home2.php file still work? I’m sure there are other php files in the genesis theme, but I’m pretty sure I’m not supposed to mess with those. I use a child theme.

    Also, I am trying to create a sidebar to go under my navbar–a horizontal area. Does simply putting in the description ‘Appears as the sidebar under the nav bar’ tell the program where to put it? It seems like there must be another step.

    I tried putting something in the widget, and it didn’t show up anywhere, so I’m sure I’m missing something. (Right now, the step 3 code is in the home2.php file.)
    I’m just learning. I really appreciate your time! Thank you.

    Reply
    • Michael David says:
      September 7, 2013 at 12:48 pm

      Well, then you have a non-standard WordPress template. This is why coding standards within WordPress are important. You should probably go back to the original designer to implement this feature….-michael

      Reply
      • Heidi@OneCreativeMommy says:
        September 13, 2013 at 10:57 am

        Thanks. I’m going to use the genesis simple hooks plugin to insert the code.

  67. Tessa says:
    September 24, 2013 at 1:08 pm

    Awesome article, very helpful!

    Reply
  68. say says:
    October 14, 2013 at 2:01 am

    Thanks for this dude! Very simple and straightforward.

    Reply
  69. Omar says:
    November 11, 2013 at 3:21 am

    Is it possible to make a sidebar on both sides?

    I think something like a three-column layout, where the main content will be displayed in the middle column?

    Reply
    • Jouke Nienhuis says:
      January 30, 2017 at 11:58 am

      Of course that is possible, but I think you already figured that out. If not, just make 2 sidebars: sidebar-left and sidebar-right. Create both files: sidebar-left.php and sidebar-right.php and make dynamic sidebar call in your index.php file. Don’t forget to register your sidebars in the functions.php and then you can easily fill your sidebars.
      Maybe a little css is also needed for the makeup

      Reply
      • njuki says:
        March 9, 2017 at 12:23 am

        You tutorial is very easy to follow. Thanks. But I still cannot figure out what tells the sidebar to appear on the left side.
        I would like my sidebar to appear on the left. Is calling it the file “sidebar-left” sufficient to achieve this?

  70. Rod says:
    November 15, 2013 at 12:18 am

    Nice, i just added a new sidebar and called to the Index.php but always appears a black dot next to any widget that i add to the new sidebar, anyway to fix this’?

    Reply
    • Michael David says:
      November 17, 2013 at 12:05 pm

      Look in your code, guaranteed you have a stray period in the code–and it’s printing to the page.

      Reply
  71. Christina says:
    November 16, 2013 at 2:06 pm

    After completing the steps – I couldn’t get a sidebar to appear in any of the templates I placed php get_sidebar(‘homepage

    So, on a whim, I placed it my footer.php and voila, it appeared there just fine.

    Any workaround for getting this into my templates?

    I’m using WooThemes ( http://demo2.woothemes.com/ontopic/2013/04/26/earning-and-learning-with-sensei/ ) with only Footer Widgets. Support is no help because it requires custom coding, beyond their assistance.

    This is a fantastic tutorial.. it has me 90% there. Any ideas? Thank you so much :)

    Reply
  72. raju says:
    November 18, 2013 at 12:55 pm

    thankx. it is so much helpful.

    Reply
  73. Kamaljeet Singh says:
    December 25, 2013 at 12:02 am

    Great tutorial thanx

    Reply
  74. Erickson Vásquez says:
    January 1, 2014 at 7:04 pm

    Thank you!

    Reply
  75. Emelie says:
    March 15, 2014 at 4:39 pm

    I have created a new sidebar but it just shows up at the bottom of the page. I want the new sidebar to be placed to the right of the page, how do I move it?

    Reply
  76. Richard says:
    May 23, 2014 at 1:16 pm

    Merci beaucoup Michael… MERCI car ton blog est complet pour réussir l’ajout d’un sidebar juste.

    THANK THANK THANK

    Reply
  77. Conrado says:
    July 14, 2014 at 9:19 am

    Great tutorial thanks.. Works like charm.

    Reply
  78. Dileesha Amarasena says:
    July 31, 2014 at 3:33 am

    Clean tutorial. Helped me straight away.

    Thanks much and highly appreciate.

    Thanks,
    Dileesha A.

    Reply
  79. Woody says:
    February 12, 2015 at 3:58 am

    Thank you, great tutorial. Good work!

    Reply
  80. Filippo says:
    July 9, 2015 at 3:11 am

    Hi, i want that my custom sidebar appear only in determinate page. I create custom sidebar files but it show always the same sidebar in all menus with sidebar, why?

    Reply
  81. Tony Scialdone says:
    July 27, 2015 at 5:18 pm

    Thanks for a very straightforward tutorial!

    I’ve had some success with it, but can’t get it working at the end. I’m sure I’m doing something wrong.

    1. I can register the sidebar fine, as it shows up in my Widgets list. I can drag widgets into it.

    2. I have a file named sidebar-internal.php:

    For testing purposes, I’ve duplicated it as internal-sidebar.php, with the custom name being “sidebar-internal”.

    3. I can’t get the stuff to display. I’ve added the following to my template:

    and

    and

    with no success.

    I’ve even started over with your exact file, filenames, and code. Any idea why the call might be in my template and NOT work to pull in the file?

    Thanks!

    Reply
    • Tony Scialdone says:
      July 27, 2015 at 5:19 pm

      Argh. Of course the php won’t post. Let’s just say I followed your instructions exactly, used your code exactly, and it won’t display. I’m using a child theme for Twenty Thirteen, that – in every other way – seems to work perfectly.

      Thanks!

      Reply
  82. Ankita says:
    April 20, 2016 at 10:18 am

    Hey Thanks a lot for this tutorial. :)

    Reply
  83. slawomir borkowski says:
    November 5, 2016 at 1:53 pm

    Thank you! Was starting to get worried I’d have to go nuclear to get this done, and even though your instructions are from five years ago, I got things working on our 4.5.4 install. LLAP!

    Reply
  84. paul says:
    June 24, 2017 at 3:37 pm

    I know this is forever old now but I’m (mostly) making it work. The sidebar shows up in my template where I put it, but when I drag a widget into the new sidebar it does nothing on the front end. Just doesn’t show up. Any idea what I might be doing wrong?

    Reply
  85. Dewinda says:
    August 26, 2017 at 5:47 pm

    Hi,
    I’ve tried this tutorial and it works!
    I can create one more sidebar in my theme
    Problem is, I want it to be in the footer area, instead it appears in header area
    Anyone can help me how to move it into the footer area?

    Thanks

    Reply
  86. May says:
    August 27, 2017 at 4:52 am

    This was helpful – thanks for sharing.

    Reply
  87. Alexander says:
    December 26, 2017 at 11:57 pm

    Thank-you for sharing this tutorial. I have been doing the same as i have seen the tutorial to create widget area https://www.wpblog.com/how-to-add-custom-widget-area-to-wordpress-themes/ . I have been adding this code in functions.php but still having issues

    function wpblog_widget()
    {
    registr_sidebar(array(
    ‘name’ => __(‘Primary Sidebar’, ‘wpb’),
    ‘id’ => ‘primary_sidebar’, // unique-sidebar-id
    ‘description’ => ”,
    ‘class’ => ”,
    ‘before_widget’ => ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ”,
    ‘after_title’ => ”,
    ));

    }

    add_action(‘widgets_init’, ‘wpblog_widget’);

    Reply
  88. Amanda says:
    September 19, 2019 at 3:55 am

    Why I am having an error while adding custom widget in my theme? This is the code that I have added in functions.php.

    function widget()
    {
    register_sidebar(array(
    ‘name’ => __(‘Primary Sidebar’, ‘wpb’),
    ‘id’ => ‘primary_sidebar’
    ‘description’ => ”,
    ‘class’ => ”,
    ‘before_widget’ => ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ”,
    ‘after_title’ => ”,
    ));

    }
    add_action(‘widgets_init’, ‘widget’);

    I have seen this code here https://www.wpblog.com/wordpress-custom-widget-area/

    Reply
  89. reply says:
    April 12, 2020 at 4:23 pm

    very helpful tutorial!!! thank you so much.

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tutorials & Case Studies

  • Analytics
  • Case Studies
  • Infographics
  • Internet Marketing
  • Local Maps and Local Listings
  • Magento
  • Mobile SEO
  • Our Book: SEO for Wordpress
  • PPC
  • Programming & PHP
  • SEO
  • SEO Power Tools
  • SEO Resources
  • Social Media Marketing
  • Web Design
  • WordPress

Our Most Recent Tutorials & Case Studies

  • Determining how and when Google Analytics 4 collects website event data
  • Infographic: Fonts & Colors That Drive the World’s Top Brands
  • Research Shows a 23% Divergence Between UA and GA4
  • How to Track Google Analytics Conversions on BuilderTrend’s iFrame Form
  • Test Results: How to Stop Google Re-Writing Your Title Tags in the SERPs

Search

Archives & Tutorial Categories

  • Analytics
  • Case Studies
  • Infographics
  • Internet Marketing
  • Local Maps and Local Listings
  • Magento
  • Mobile SEO
  • Our Book: SEO for Wordpress
  • PPC
  • Programming & PHP
  • SEO
  • SEO Power Tools
  • SEO Resources
  • Social Media Marketing
  • Web Design
  • WordPress

Austin SEO Company, TastyPlacement

Click Here to Explore a Free Consultation

Our Most Popular Services

  • Austin SEO [Home]
  • WordPress SEO Service
  • PPC Management
  • Social Media Marketing
  • Analytics and Monitoring
  • Remarketing Experts
  • Conversion Rate Optimization

Let’s Talk: How to Get in Touch With Us

TastyPlacement
4150 Freidrich Ln Ste C
Austin, TX 78744
Tel: (512) 535-2492


Get Directions or Read Our Awesome Reviews on Google Maps
© Copyright - TastyPlacement. Made in Austin, Texas
  • Twitter
  • Facebook
Siri Search Optimization Video Tutorial: How to Clean Up Your WordPress Head
Scroll to top