DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Variable Sidebar
<div id="sidebar">
<?php
// let's generate info appropriate to the page being displayed
if (is_home()) {
// we're on the home page, so let's show a list of all top-level categories
echo "<ul>";
wp_list_cats('optionall=0&sort_column=name&list=1&children=0');
echo "</ul>";
} elseif (is_category()) {
// we're looking at a single category view, so let's show _all_ the categories
echo "<ul>";
wp_list_cats('optionall=1&sort_column=name&list=1&children=1&hierarchical=1');
echo "</ul>";
} elseif (is_single()) {
// we're looking at a single page, so let's not show anything in the sidebar
} elseif (is_page()) {
// we're looking at a static page. Which one?
if (is_page('About')) {
// our about page.
echo "<p>This is my about page!</p>";
} elseif (is_page('Colophon')) {
echo "<p>This is my colophon page, running on WordPress " . bloginfo('version') . "</p>";
} else {
// catch-all for other pages
echo "<p>Vote for Pedro!</p>";
}
} else {
// catch-all for everything else (archives, searches, 404s, etc)
echo "<p>Pedro offers you his protection.</p>";
} // That's all, folks!
?>
<form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div>
<input type="text" name="s" id="s" size="15" />
<input type="submit" value="<?php _e('Search'); ?>" />
</div>
</form>
</div>





