Orangescale Studio

You're here: Home » Blog » Understanding WordPress Widgets

Understanding WordPress Widgets

by Thomas Arie Setiawan — April 13, 2006

Few days ago, WordPress released a new plugin called WordPress Widgets. I do not use WordPress as my blogtool, but I have been there for quite long time. I am maintaining a WordPress theme called Laila, together with Lala.

What is it all about?

If you're using WordPress, you can take advantage from the theme system in managing the item in the sidebar. In the Main Index Template called index.php, you can see this line <?php get_sidebar(); ?>. So, if we want to change the item in the sidebar, just modify this file. Only this file.

Before using the widgets, if you want to change the "item order", you need to edit this file directlry. Okey, this is an example:

<div class="side-c">
<h3>The Author</h3>
<p><?php the_author_description(); ?></p>
</div>
<div class="side-c">
<h3>Calendar</h3>
<?php get_calendar() ?>
</div>

Using that kind of tags, you will the "author box area" and "calendar box" in the sidebar. Pretty easy. But what if you have many items in your sidebar, and you want to change the order? For example like this:

  • Author info
  • Recent entries
  • Calendar
  • Recent comment

Now, you want to change the order to be like this:

  • Recent entries
  • Recent comment
  • Author info
  • Calendar

If you want to have that kind of changes, usually you will edit your sidebar.php, and change the order manually. But, if you were using the widget, you can do it easily. Take a look at this image.

You can change the order by dragging and dropping the available widgets to the box called "Sidebar 1".

Make sure your theme supports this plugin

Of course, you can not have the widgets in action only by installing the plugins; you need to modify the sidebar too. In Laila theme, I put these lines and removing some existing items.

<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : else : ?>
<?php endif; ?>

If you want to find out more about this widget, please go to the WordPress Widget Blog.

"I use this WordPress widget, but..."

For those who want change the order instantly, this widget is probably a good solution. I am not surprised if many WP users say "Wow!" about this.

When I installed this plugins and modify the sidebar for the Laila theme, many questions came to my mind:

  • What if I want to have different sidebar in different page? Using is_home() or is_single() conditional tags will be easier.
  • I know that I can have multiple sidebar. I have tried it, and it worked. The problem is that I can only have one widgets for each item. It is possible to have duplicate items (for example: 2 recent comments widget items, 3 recent entries widget items) so that the they can be combined with the conditional tags as I mentioned above?

Overall impression: nice and fancy. And I am stick with Textpattern.