Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to widgetize a WordPress blog theme


If you are using wordpress as you are new,more than likely all of the themes you are looking at using are widgetized. For that special occasion that your Wordpress Blog Theme isn’t widgetized, here’s a simple way of how to hack your theme, and with just a little bit of code, you can widgetize your theme.

As official page from Automattic says:
Instead of register_sidebar() you should use register_sidebars(n) where n is the number of sidebars. Then place the appropriate number in the dynamic_sidebar() function, starting with 1. (There are several other ways to use these function. See the API). You can even give your sidebars names rather than numbers, which lets you maintain a different set of saved sidebars for each theme.





Now You can edit this in the functions.php file. If you don’t have a functions.php file, then you probably don’t have a widgetized theme. Here’s an example of some code that you could put in your functions.php file:

Step 1:-

Look for functions.php (Create one if you don’t have). Insert the following code into it, save and close. We are done with functions.php. Basically what this codes does is – it register the sidebar as dynamic.



if ( function_exists(‘register_sidebar’) )
register_sidebar();
?>


Step 2:-

Here’s how a typical sidebar.php will look like.



What you need to do here is to enclose an an-if statement into sidebar.php. The addition of codes are in bold.



You are Done!!


This post first appeared on SimpleBloggerTips, please read the originial post: here

Share the post

How to widgetize a WordPress blog theme

×

Subscribe to Simplebloggertips

Get updates delivered right to your inbox!

Thank you for your subscription

×