0

How To Widgetize Non-Widget WordPress Theme

  • Unknown
  • Share
  • 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. Thank you to Daniel who tipped me on this, I’ll share this on your behalf since you are not writing a tech blog :)

    0 Responses to “How To Widgetize Non-Widget WordPress Theme”

    Post a Comment

    Subscribe