Widgetize non-widget WordPress theme

On March 6, 2009, in Wordpress, by Yao Yuan

widgetize non widget theme
Consider this – If you found a WordPress theme that you like so much but it is not widget-supported, don’t give up just yet. Methods below helps you to widgetize non-widget theme to a drag-drop widget theme. Download Widget plugin from Automattic, upload them accordingly and follow the 2 steps below.

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.

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

Step 2

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

<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>
<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(); ?>
</div>

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

<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. The theme now is now widgetized. You can now do the drag-drops like the widget themes. Here’s a goodWordPress widget resource.

===============================================================

Related posts:

  1. Execute PHP in WordPress post, page and Widget Sidebar If you are still struggling on how to insert PHP...
  2. WordPress Theme That Mimics Mac OS X Leopard – Leopress here’s the WordPress theme that gets very close to a...
  3. Something Useful for creating a WordPress theme people wanting to know how to create a WordPress theme....
  4. My wp’s theme “elements-of-seo” Elements of SEO WordPress Theme is not designed by me,but...
  5. How to Fix Unexpected WordPress Database Table Error Two days ago, out of nowhere, a particular table in...

Related posts brought to you by Yet Another Related Posts Plugin.

Tagged with:  

Leave a Reply

You may interested this