Home » wordpress

Wordpress Widgets Wherever

28 June 2008 206 views 8 Comments

If you are a Wordpress user then you know how much of a saviour widgets has been. Long gone are the days of keeping your sidebar.php file open to make edits every time you need to add a plugin. And among the many who’ve spent hours customizing their sites only to accidentaly make a typo in the file and mess up your whole site widgets have eliminated that worry. Now when you add a plugin that supports widgets you simply use a drag and drop interface to place the plugin where you want it to display.

If you didn’t know this already you can actually use widgets in other places on your website and not just the sidebars. For example at the bottom of this post just above the comments form is a section that lists related posts. In the past I would have to edit the file single.php and after installing the Related Posts plugin and add some php code to the file for it to show where I want it. Now I can just go to my widgets section in Wordpress and add whatever I want down there as a widget instead of editing php code. You could do the same thing for your header or footer or anywhere else on your site.

To do this edit the file functions.php inside your theme’s folder and look for the function to create a widget, it will look like this:

if ( function_exists('register_sidebar') ) // Sidebar Widget
    register_sidebar(array(
        'name' => 'Bottom of Post',
        'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ));

Copy and paste that code and create and second and even third copy if you want one after the other and then change the name of it to something unique. Next open the theme file that you want to add this new widget section to and add the following code:


Default left sidebar stuff here…

Now when you go to your widgets section you will see another menu you can customize from the dropdown section. Do this as many times as you need to.

widget setup

RSS feed | Trackback URI

8 Comments »

Comment by Sherin (3 comments)
2008-07-13 06:04:43

Seems this is a niche idea. Most powerful and helpful for wordpress blog. I hope I can use the same to my word press blog. Is there any version of this available for blogger bloggers?

Sherin

 
Comment by Bridal Showers (1 comments)
2008-11-20 15:56:12

Great post, Cleared many doubts,Will be looking forward to using the technique in the coming projects. Thanks Cheers

 
Comment by Champion Sawyer (1 comments)
2008-12-05 14:45:49

Very interesting post. Nice blog by the way!

 
Comment by Spicy Forex (1 comments)
2008-12-08 12:29:33

Hey, great post there! Im first time here visited your blog, definitely will visit back later, keep it up :)

 
Comment by Sabac | Autoclaves Australia (1 comments) Subscribed to comments via email
2008-12-27 10:22:59

There are many widget ready themes available and there are many widgets available as well. Thanks for sharing the code and way it works. At least I know now how we can implement our own codes or widgets. Wordpress makes our lives so easy and wonderful.

 
Comment by how to make money online (1 comments)
2009-01-01 03:40:18

i’m actually wondering how they put those plugins up. hehe, thanks for the info, i’m a newbie wp user.

 
Comment by Web Design Los Angeles (2 comments)
2009-01-02 07:01:10

Great insights. I was not aware of this. You have nicely described. This information also helps to those who have no idea about it. Thanks for sharing…

 
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.

Comments links could be nofollow free.

Trackback responses to this post