Home » Blog Consulting and Advice, Software, Web Development

Sidebar Widgets – To get the most out of it

19 February 2007 2 views 3 Comments

I had the sidebar widgets plugin installed on my wordpress system since day 1 but I never really figured out to use the juice of it until tonight.

I had did not know how to add my own widgets within the dynamic sidebar, which is why all add-on items such as my Google ad, John Chow’s Widget, MyBlogLog Avatar plugin and what not were taking on the top only, never in the middle. But today I went down to work and discovered that adding new widgets to the sidebar in both PHP and HTML is rather simple. Here is a brief explanation for those who are more code-savvy.

  1. To add sidebar items that consist of Javascript/HTML/Text only

    Simply go to the plugin options page in your admin panel (under Presentation) and add a text-widget. To define the # of text widgets available, scroll down below. I just have this to the maximum # which is 9, in order to have flexibility to add more stuff.

    sidebar-text-html-items.jpg

    For any HTML/Javascript/Text sidebar items, simply use this option. It’s easier.

  2. For PHP, you need to add a sidebar widget in the plugin PHP file, which you can find under (if you installed it this way, of course) wp-content/plugins/widgets. In that file, scroll to near the bottom where you see a bunch of functions being added.

    My first widget of choice was the Top Commentators Widget. This widget shows you the top commentators, of course.

    my-own-widgets.jpg

    This widget was installed using generic PHP code given by the authoer, and now it is an item that I can drag-and-drop to re-arrange on my Wordpress Admin section.

    Here’s how I created the code, in case you want to copy me :

    function widget_topcommentators($args) {
    extract($args);
    ?>

    <?php if(function_exists(‘ns_show_top_commentators’)) { ?>
    <li>
    <h2>Top Commentators</h2>
    <ul><?php ns_show_top_commentators(); ?></ul>
    </li>
    <?php } ?>

    <?php
    }
    register_sidebar_widget(‘Top Commentators’,'widget_topcommentators’);

So now, I have completely control over my sidebar widgets, whether it be a Javascript item or a PHP item. And my sidebar is all cleaned up now!!!

Share and Enjoy:
  • Twitter
  • Facebook
  • StumbleUpon
  • Propeller
  • Digg
  • Technorati
  • Sphinn
  • del.icio.us
  • Mixx
  • Google Bookmarks
  • Print
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

RSS feed | Trackback URI

3 Comments »

Comment by Silvano Vilela Subscribed to comments via email
2007-03-02 20:37:40

I place the code in sidebar that already it exists or make another one. I placed in sidebar that it exists and of the error.

Comment by Jeff Kee
2007-03-03 11:32:23

you’re gonna have to write that again. Sorry, i can’t understand it.

 
 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

Trackback responses to this post