Adding Widgets To Your Sidebar

If you are using a custom theme made by somebody other than yourself most likely you won’t have any idea on how to get widgets to work in your blog’s sidebar. So I decided to write up this post detailing how to do it and show you how extremely easy it is.
As a quick overview and for those of you unaware of what the hell I’m talking about let me explain really quick. A widget is a item that you can dynamically insert into your blog’s sidebar that adds extra functionality. Some of the default widgets provided by WordPress are recent posts, calendar, categories, tag cloud and so forth. So enough of my yapping, lets get to coding.
Most WordPress Theme developers will usually use a sidebar.php file in their themes. So with that said I am going to assume that there is at least 1 sidebar.php file in your current theme’s folder. Navigate to your theme’s folder and look for the sidebar.php file. If you have 2 sidebars it may have a number next to it. Open it up and you should see some PHP coding. This is where it can get tricky for those of you with no coding experience, but I will try to make it as easy to understand as possible.
When you insert the code I am about to give you the widgets are going to be inserted wherever you insert the code. If you already have some things in your sidebar you need to decide where you would like the extra widgets to show up. If you decide to place the code between some things in your sidebar just remember that when you place a widget it will bump whatever is below the widget code down. So the more widgets you add the further down the rest of the items in your sidebar will drop.
Here is the code that we are going to be using….
<?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar() ) ; ?>
Make sure to copy and paste this code exactly, things can really get screwed up if even one character is off. Once you have the code copied, find a place in your sidebar where you would like widgets to display and paste the code there. Save your file, upload it to your server and you are all set. Now all you have to do is go into your WordPress Administration panel, click on Design then on Widgets and select which widgets you would like to show up in your sidebar.
What did you think it was going to be more complicated than that? Sure it may take some practice to get the code in the right spot to get things to show up how you want them to. But don’t fret if you can’t figure it out, if you are stuck you can always get ahold of me and I’ll do what I can to get it working for you :)
Twitter
FaceBook
RSS
Hi,
Thanks for this posting. But I’m still a bit stuck. I’d like to add a sidebar to “just” by blog page. The sidebar should have archives and categories. When I add a widget to the sidebar is shows up everywhere vs. just on a certain page.
Hope this makes sense.
Hi Josh, are you talking about the website that you used for your URL in the comment? If so, you would need to edit the code in your sidebar.php file and use an IF statement to determine which page you were on and then only show the widgets for that particular page(s).
It would look something like…
if (is_page('PageTitle')) {
show the widget
} else {
don't show the widget
}