Changing the Blog Sidebar in WordPress
Blog’s all have a navigation column and in WordPress, this is called the Sidebar. The actual file that controls this located in your themes/ directory and is called sidebar.php. If you want to add things like advertisement to your sidebar, this is the file to edit. Notice, if you change your blog theme, you will have to edit the new sidebar.php in the new theme. Today, I will show you how to find this file and how to edit it.
Before we get started…
First, let’s find our theme so we know which sidebar.php to edit. In your WordPress admin, select Presentation from the top navigation and then select Themes in the lower navigation when it appears. This will show you what theme you are currently using and also the themes you have installed and are available to use. On this blog, I am using the default theme. Now that I know which theme is being used, we need to fire up our favorite FTP application and FTP into our website to the wp-content/themes/(theme_name) directory. The theme_name in mine is default/. This is where all the files are kept for each of the pages and sections that WordPress uses. Changes can be made to the Header and Footer by editing header.php and footer.php respectively. Today, we are going to download sidebar.php and open it in our favorite editor. Notepad will work if you don’t have a favorite. Word or any Rich Text editor will NOT work though.
View sidebar.phps and keep it open for reference. It is what I will be using for my example. It is the default sidebar.php for WordPress. If you are using the default theme, it should be identical. If not, you will have to do some figuring. I recommend doing your learning on a test install with the default theme in place.
Once you have sidebar.php opened in your editor, you will see php tags and the stuff in between them and ?> is php code. This is the stuff that makes the WordPress script work. Leave them all alone! and everything in between them! They are well out of the scope of this article.
This is a bit tricky because of the way WordPress handles their templates. Personally, I have this love/hate thing going for how WordPress does things. This is also going to get tricky because of how I handle things. I really like to use includes. This keeps sections all tidy and by them selves and if I monkey with the design I am not likely to break my advertisements and vice versa.
What I am going to do is add the Syndication Chicklets and the viral bookmarking links to the sidebar.php as an include. Anything you want to add to the sidebar is done in this basic manor. If you do not want to use includes, instead of putting in the include calls, just put in whatever you are adding to sidebar.php.
View chicklets.phps and you will see the file that will become my include file. You may just copy it and use it as is on your WordPress install. This include file will NOT work with anything but WordPress or WordPress MU.
In my case, I put the file in includes/ and the php call to get it to appear is:
A longer form of this with a bit of error trapping to prevent train wrecks would be like this:
$include_file = "includes/chicklets.php";
if (is_file($include_file)) {
include($include_file); // include it
}
?>
View new_sidebar.phps and you will see where I added the code starting on line 57 (do a find on the text “this is where i put the include for the chicklets ” if needed). This will pull the chicklet’s in just above the Meta Links. Move it around and see how it works and find out where you want yours. You will see my live version is a bit different.
This is how you add stuff to your sidebar.php or any other WP file.
I will explain the calls used in the chicklets in a later article.
Till then, hope this helps!
Tags:chicklets footer hacks header howto modifications php sidebar themes wordpress wordpress mu






Stuart,
There is no set rule to how many images you can or should use in the sidebar. It really depends on your site, your traffic, what you are trying to do and personal taste.
I will go over the way I tend to do sidebar’s in the future and that may help you get the answers you are looking for. Or at least help you figure out a method for yourself.
That said, basically, I try and mix my advertisement in pretty well with the navigation and other sidebar things. Many Surfers have become virtually blind to advertisement, so some thought has to be put into making it so they not only see it, but click it.
Keep in mind, this is a fine line to walk. If you make your navigation awkward you will lose visitors. No visitors means no revenue to those ads.
At this time, you will notice this blog seems pretty devoid of advertising except for some Google stuff… but let me suggest you look a tad closer at what is in the sidebar. After a few minutes of careful study, you should start to see where the potential advertisement is. (Hint: at the time of this writing, there are 3.)
As I continue to build this blog up, the ads will get more and more obvious, but they will also get even more subtle.
Basically, to try and be helpful without writing the article on it in this reply, I would build the site and the navigation (as I have done here) and then I would start adding in the advertisements.
Chances are, in the next few days, you will see a nice and obvious ad at the top of the sidebar, then some of the normal sidebar stuff for about 100 pixels or so, another ad, more navigation stuff for 100 px or so, another ad, and so on.
Be on the look out for my article that goes into this in detail.
Thanks for your question!
Short answer for Stuart:
There is no “normal” so put as much as you want/need.
Optimal would be where the ads received the most clicks.
Put some ads up and watch how your traffic reacts.