HowTo: Convert Non-Widget to Widget Ready WordPress Theme

This is really awesome. Many a times I have loved a theme, but I shy away from using it. Why? I know nothing about coding and I would prefer to have have widget ready themes. Over last couple of weeks, I have surely learnt that all plugin and widget ‘functionality’ lies in the functions.php!

Infact, last week I borrowed some cool functionality from one theme and massaged that into my other theme. Wow, it worked! So, here is a how-to for converting non-widget ready theme to a widget ready theme!

Functions.php is the file you should be looking for. Insert this code in the file

<?php
if ( function_exists(’register_sidebar’) )
register_sidebar();
?>

Now you need to modify your theme’s sidebar.php

Typically

<div id=”sidebar”>
<h2>Search this site</h2>
<div id=”searchdiv”>
<form id=”searchform” method=”get” action=”<?php echo $_SERVER[’PHP_SELF’]; ?>”>
<input type=”text” name=”s” id=”s” size=”20″/>
<input name=”sbutt” type=”submit” value=”Go” alt=”Submit” />
</form>
</div>
//
<?php if ( !function_exists(’dynamic_sidebar’)
|| !dynamic_sidebar() ) : ?> // added

//
<h2><?php _e(’Archives’); ?></h2>
<ul><?php wp_get_archives(’type=monthly’); ?></ul>
<h2><?php _e(’Categories’); ?></h2>
<ul><?php list_cats() ?></ul>
<h2><?php _e(’Meta’); ?></h2>
<ul>
<?php wp_register(); ?>
<li><a href=”<?php bloginfo(’rss2_url’); ?>”>RSS</a></li>
<li><?php wp_loginout(); ?></li>
</ul>
<?php wp_meta(); ?>
//
<?php endif; ?> // added
//
</div>

That’s it! You are all sorted mate to have a widget ready theme! Give it a shot. Its straight forward!

No comments so far

  1. [...] Nakar gives really simple instructions on how to take your non-widget theme and make it widget-ready. So far widgets and I haven’t [...]

  2. Manu Khanna February 27, 2007 7:28 am

    The steps you’ve mentioned sound very simple but I could not reproduce the results in my blog. Can you help me out my having a look at my theme and tell me what do I need to change and where?

    I have placed a zip of my theme files at http://manukhanna.com/2813.zip.

    much appreciate.

  3. Alpesh February 27, 2007 12:51 pm

    Manu,
    I will try to have a look. But this theme comes with sidebar widgets, sidebar modules (you need a plugin for that though). How can you widegetize an already widgetized theme :-)

    Cheers!
    Alpesh

  4. Ben March 5, 2007 8:25 am

    I was hoping to upgrade this theme my client wanted to use “falling-leaves-09″ to use widget and was excited to find your post. However, there is no funtions.php in the theme’s files. :-/

  5. Alpesh March 5, 2007 1:14 pm

    Hi Ben,
    Hmm no functions? Strange. Possible to upload the theme for me to have a look at.

    Cheers!
    Alpesh

  6. Alpesh March 7, 2007 2:20 pm

    Hi Ben,
    Create a functions.php file – copy from here

    < ?php
    if ( function_exists('register_sidebar') )
    register_sidebar();
    ?>

    Let me know how you go with this.

    Cheers!
    Alpesh

  7. Giovanni March 20, 2007 3:54 am

    I know convert one sidebar to widget ready…
    but I need 3 collum themes,
    one sidebar left (main content) right sidebar

    I tryed everything but every time goes wrong…
    can you help me ?

    since now thanks…

  8. Giovanni March 20, 2007 3:58 am

    :) I found it how to make two sidebar widgetized !!!!

    thanks… :)

  9. Alpesh March 20, 2007 11:34 am

    Congrats Giovanni.

    Would you share that with other users/readers of this site?

  10. Giovanni March 20, 2007 9:16 pm

    To make two sidebar widget, first do:

    File = functions.php

    File sidebar.php

    In the sidebar you should put two parts of code, in the begin you should copy and paste the follow code:

    At the end of the sidebar.php you should copy and paste this code:

    What does it mean ? These lines tell wordpress to show dinamic sidebar if exist, if don’t, than wordpress show the default sidebar…

    Here it is. To create the second widget sidebar, you have to create other “sidebar” file, you can copy your sidebar.php and rename as sidebar2.php or whatever you want, the name doesn’t matter. Just make a copy of your sidebar.php and rename.

    Now, open the sidebar2.php and do the same as before, put the follow code:

    At the end of the sidebar2.php you should copy and paste this code:

    Now, it’s almost done, but… you have to include the second sidebar ok ? To include sidebar2.php in your template you have to decide if you sidebar will appear only on “post pages” or only in “page templates” or “archives templates”.. I made my 2 sidebars appear in every page of my site.

    To include the “sidebar2.php” in any template you have copy and paste the follow code:

    It’s not a trick but I think this may help some of them:

    If you want to put “sidebar in left side, main content, sidebar in right do this:

    “first you call =
    “than you call = the content

    and finally you call =

  11. Alpesh March 29, 2007 9:20 am

    HI,
    Thanks for sharing the code. It got usurped since its a code. I would suggest you to email me the code and I will post it here or if you want to enclose the code in

    your code

    it might work.

    Look forward to your response.

  12. Alpesh March 29, 2007 9:21 am

    Oops.. just email me.

  13. Giovanni March 29, 2007 9:28 am

    I will send you the code, tomorrow, now I’m f* busy you don’t believe ! rsrsrs :)

  14. Alpesh March 29, 2007 10:16 am

    No worries. I have just edited your comment… :-)

  15. [...] Remember : Some themes are different, so make sure you check where do actually put this code. This is a scaled down version; for more information, click here. [...]

  16. [...] How about that? They included that widget stuffing finally. I always thought it would be something meaningful. But truthfully, a widget is nothing else then isolating parts of that sidebar and make them ‘drag/drop’ for morons. It has no value for a template developer that isn’t attempting to share the template with anybody else. Well, not on purpose anyways. Just so I don’t forget, here’s how to make themes ‘widget ready’: Automattic & Alpesh Nakar. [...]

  17. [...] HowTo: Convert Non-Widget to Widget Ready WordPress Theme [...]

  18. [...] HowTo: Convert Non-Widget to Widget Ready WordPress Theme [...]

  19. Konvict April 17, 2008 2:06 pm

    Hey, i did this however i get an error when ever i try to update a plugin or any updates.

    Warning: Cannot modify header information – headers already sent by (output started at /home/www/gamecareers.com.au/wp-content/themes/rin-11/functions.php:1) in /home/www/gamecareers.com.au/wp-includes/pluggable.php on line 689

    My theme didn’t have a functions.php file i had to create one.

    What should i do? If i remove my functions.php file and try to update things, etc… its all fine but when i upload my functions.php file and try to update things it goes crazy.

    Nice article, really helpful though.

    Jamie

  20. Vina November 12, 2008 6:31 pm

    Hi, i’m trying to widgetizing Maggo template from http://www.wpthemedesigner.com/2008/06/25/maggo-mag-theme/

    it has no functions.php so I created one consists only

    also, adding its sidebar-left and sidebar-right with this:
    (very begining of line)

    and the end of code

    but nothing changed. am I on the right track or .. why do i feel lost ^^ ??
    thanks for your kindness

  21. Rahul February 23, 2009 11:06 pm

    Hey, I need help with my sidebar widgetization. I have tried to do everything you said many times and after editing my page goes completely blank. Please help me out here.

    The theme I am using is can be downloaded at this link:

    http://wordpress.siteground.com/wp2.5/?wptheme=siteground-wp64

Leave a comment