Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Ezilon Directory   Improve your ranking, submit to directories   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 07-25-2008, 05:24 PM   #1 (permalink)
Super Moderator
 
StarLab's Avatar
 
Join Date: 10-29-07
Location: Ontario, Canada
Posts: 1,327
iTrader: 0 / 0%
StarLab is a highly respected web proStarLab is a highly respected web proStarLab is a highly respected web proStarLab is a highly respected web proStarLab is a highly respected web proStarLab is a highly respected web proStarLab is a highly respected web proStarLab is a highly respected web proStarLab is a highly respected web proStarLab is a highly respected web proStarLab is a highly respected web pro
Send a message via ICQ to StarLab Send a message via MSN to StarLab Send a message via Yahoo to StarLab
Widgetizing WordPress Themes

How many times have you been shopping for WordPress Themes only to be disappointed that it doesn't support widgets?

Widgetizing a theme is drop-dead simple!

So save that Theme because in 3 easy steps, you can recode it to support widgets.

(Disclaimer: Don't yell at me! Backup your theme first. Have a quick restore option handy )

Step 1

Locate "sidebar.php" in your theme directory. (Note: Code will vary!!) Load it up and you will see something like this:

PHP Code:
<div id="sidebar">
<ul>    
<?php wp_list_pages('title_li=<h2>Main Menu</h2>' ); ?>            
    <li><h2><?php _e('Categories'); ?></h2>
    <ul>
    <?php wp_list_cats('sort_column=name'); ?>
    </ul>
    </li>

    <li><h2><?php _e('Archives'); ?></h2>
    <ul>
    <?php wp_get_archives('type=monthly'); ?>
    </ul>
    </li>

        <<<<Snip!>>>> <-- To keep this brief :) 

</ul></div>
There is more code, but basically you want to remove any code that makes up the sidebar that you wish to replace with widgets. (wp_list_pages, wp_list_cats, etc)

Step 2

In the example given here, we replace all that with this:
PHP Code:
<div id="sidebar">
<ul>
<?php if ( !function_exists('dynamic_sidebar')
        || !
dynamic_sidebar() ) : ?>
<?php 
endif; ?>
</ul></div>
Save and upload this to your server.

Step 3

Find and load "functions.php" (If it doesn't exist, create it) Make sure the file contains this line:
PHP Code:
<?php if ( function_exists('register_sidebar') )register_sidebars(2);?>
Save/create and upload this as well.

Now you can activate and use widgets. You may need to adjust some CSS, depending on how the theme was coded, but you should be done.

You can also run a combination of both coded and widgeted sidebars:
PHP Code:
<div id="sidebar">
<ul><li><h2>Main Menu</h2>
    <ul>
    <li><a href="http://www.example.com/about/"  title="About example">About example</a></li>
    <li><a href="http://www.darkstarretroproject.com/" title="Back to the Home Page">Home</a></li>
    </ul>
    </li>    

<?php if ( !function_exists('dynamic_sidebar')
        || !
dynamic_sidebar() ) : ?>
<?php 
endif; ?>

    <li><h2>W3C Valid</h2>
    <ul>
    <li><a href="http://validator.w3.org/check/referer" title="<?php _e('This page validates as XHTML 1.0 Transitional'); ?>"><?php _e('Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr>'); ?></a></li>
    <li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://www.example.com"><?php _e('Valid  <abbr title="Valid Css!">CSS</abbr>'); ?></a></li>
    </ul>
    </li>
</ul></div>
Hope someone finds this useful.
__________________
Larry - Addicted to Coffee and Proud of it!
[DarkStar Retro Project] - A world wide search for ultra-rare software.

"Writing is the most fun you can have by yourself!" --Terry Pratchett
StarLab is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
50 Quality Wordpress Themes Wordpressthemesbox Templates and Themes 0 05-20-2008 02:46 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 09:49 PM.
© Copyright 2008 V7 Inc