Currently viewing the tag: "non widget theme"
I had a huge huge headache the last time when I didn’t have widgets on my blog. So I’m revisiting this tutorial again. Basically what you have is a theme which is not widget ready.. ugh, even the mention of that sickens me. What I’m going to share is how to create a widget for your sidebar on your non-widget ready theme.First of all, please go to this site. This is the real guru for widgetizing a theme What we would like is to have this page on wordpress.

Wordpress Widgets

 and not THIS!

Wordpress Theme No Sidebars

When you find your sidebar.php.. it will have code that looks something like this – base on widget sidebar of Kubrick the classic wordpress theme.
<div id=”sidebar”> <li id=”about”> <h2>About</h2> <p>This is my blog.</p> </li> <li id=”links”> <h2>Links</h2> <ul> <li><a href=”http://example.com”>Example</a></li> </ul> </li> </ul>
Looks quite terrifying yes? No worries, then from here what you do is you just add these two lines into it.
<ul id=”sidebar”>  <?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar() ) : else : ?> <li id=”about”> <h2>About</h2> <p>This is my blog.</p> </li> <li id=”links”> <h2>Links</h2> <ul> <li><a href=”http://example.com”>Example</a></li> </ul> </li> <?php endif; ?> </ul>
That’s it! oh WAIT  no not yet! You have to create a functions.php file for it if your theme doesn’t already have one. Don’t fret, just open up either dreamweaver or even a note pad and save the file as  functions.php and this is what you have to type in it
<?php if ( function_exists(‘register_sidebar’) ) register_sidebar(); ?> 
If you need more than one sidebar no probs just key this in.
 <?php if ( function_exists(‘register_sidebars‘) ) register_sidebars(n); ?> **(n) n refers to the number of widget sidebars you want to register.
If you look at the new wordpress 2 themes and above they would have a function page that looks like so
<?php if ( function_exists(‘register_sidebar’) ) register_sidebar(array( ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”sidebartitle”>’, ‘after_title’ => ‘</h2>’, )); ?>
HAHHH???? what the heck where did that code come from? I had another headache because, great now where am i going to add this section  register_sidebars(n) in? Well it was quite simple it seems, you just put the number here
<?php if ( function_exists(‘register_sidebars‘) ) register_sidebars(n,array( ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”sidebartitle”>’, ‘after_title’ => ‘</h2>’, )); ?>
So yeah, that was my widget headache solution. Hope this helps out anyone out there.