How to add a widget to the sidebar

There are basically two ways to add widgets to the sidebar. The easy one for people who use a widget-ready theme, and then there’s the way for people who are either using a non-widget-ready theme or are weird German guys with too much time on their hands, who prefer to mess with the code. Uhm, yeah, that would be me.

The easy way

Go to your admin panel and click on presentation. Under “widgets” you see your sidebar(s). Don’t worry, that’s just the widgets. The non-witgetized parts of the sidebar are not shown. You didn’t lose them.

Widget - opens in new windowDrag a “Text 1″ widget into your sidebar.

Click the configure button on the right.

Paste the code you copied from the widget provider (i. e. BlogCatalog) into the big text field.

Close it, click “Save Changes” and you should be set.

The harder way

Open your sidebar.php in a text editor. I prefer to have the widget above the meta section of the sidebar, so I look for it in the code. Ah, there it is.

<li><h2>Recent Entries</h2>
<ul>
<?php query_posts(’showposts=10′); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title() ?></a></li>
<?php endwhile; endif; ?>
</ul>
</li>

<li><h2>Meta</h2>
<ul>

It will look different in your theme. Just make sure you found the meta part. Before you edit anything, you should make sure that you have a backup copy of the file. Now I will paste the code from the widget provider into the theme, which results in this:

<li><h2>Recent Entries</h2>
<ul>
<?php query_posts(’showposts=10′); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title() ?></a></li>
<?php endwhile; endif; ?>
</ul>
</li>

<ul>
<li><script type=”text/javascript” src=”http://www.blogcatalog.com/w/recent.php?id=XXXXXX”/script></li>
</ul>

<li><h2>Meta</h2>
<ul>

As you can see, I also gave it ul and li tags, to match the rest of the sidebar. Save the file, upload it to your ftp, thus replacing your old sidebar.php. You should be able to see your shiny new widget now.

I hope this was of help to you. If it was (even if not), drop me line. I’m always interested in feedback.


Share This

Popularity: 44% [?]

Tags: , , ,
Share Results

5 Responses to “How to add a widget to the sidebar”

  1. I tried the hard way once and broke my blog…thank god for drag and drop!

  2. Thanks, this was really helpful

  3. For those who break their blogs like Andy, try any changes you want to make on a test blog first. Keep your test blog as similar to your original one in production.

  4. sometimes, widgeting end up my blog into mess. So, i better don’t this to better control of my sidebars.

  5. Private Servers on February 12th, 2011 at 2:13 pm

    Habbo Retros…

    Habbo Retros are slowly attracting more users with each passing day, most people prefer to play Habbo Retros with pets according to a recent google study, further evidence also supports that Habbo Retros have lead to an annual decrease in revenue for s…


Close
E-mail It
Socialized through Gregarious 42