How to widgetize your theme in Wordpress

/* Posted May 5th, 2008 at 10:52am */
/* Filed under Blogging, Programming */

/* */

wordpresstitle1 How to widgetize your theme in Wordpress

Make a file called functions.php in your theme directory. (if you don’t have one yet)

Add the following code and save the file:

if ( function_exists(’register_sidebar’) )
register_sidebar(array(
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ‘

‘,
‘after_title’ => ‘
‘,
));
?>

Then add the following anywhere you want to add dynamic widgets:

< ?php if ( !function_exists(’dynamic_sidebar’)

|| !dynamic_sidebar() ) : ?>

< ?php endif; ?>

You can actually put your existing code within the if loop OR you can also put it before or after.

Since I didn’t want to widgetize all existing stuff, I simply put it after all my existing code in my sidebar.

You can also create multiple dynamic widget locations simply by add numbers to the code like this:

< ?php if ( !function_exists(’dynamic_sidebar’)

|| !dynamic_sidebar(1) ) : ?>

< ?php endif; ?>

  • Twitter
  • Digg
  • del.icio.us
  • Propeller
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Mixx
  • Yahoo! Buzz
  • NewsVine
  • Facebook
  • Google Bookmarks

Related Posts


Related Videos

Using WordPress To Make… (3of6) Alan Watt -… (5of6) Alan Watt -… (1of6) Alan Watt -…

Related Stories

Related Tweets

Leave a Reply

or Login (not required)





HTML tags allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>