Pintsize sidebar.php

sidebar.php

Usually included in a wordpress template by a <?php get_sidebar(); ?> command. This code creates a default version of code for the sidebar.

The if statement at the top of sidebar.php tells WordPress that if there are no Widgets set up in the Widgets area under Appearance, then this list of default widgets will be shown. If even one widget or more widgets are set up in the Widgets area, then this whole list will be replaced with the newly defined widgets, one or many.

<div id="sidebar">
    <!-- if a dynamic sidebar exists and no sidebar widgets are set up, show these widgets -->
    <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar Widgets')) : else : ?>
        <!-- All this stuff in here only shows up if you DON'T have any widgets active in this zone -->
        <h3>Pages</h3>
        <! -- wp_nav_menu: show links in sidebar-menu set up Appearances => Menus -->
        <?php wp_nav_menu( 
           array(
               'container' => '',
               'menu_id' => 'menu',
               'theme_location' => 'sidebar-menu'  ) ); ?>
        <h3>Recent Posts</h3>
        <ul>
           <!-- Show 5 most recent post titles -->
           <?php
	      $args = array( 'numberposts' => '5' );
	      $recent_posts = wp_get_recent_posts( $args );
	      foreach( $recent_posts as $post ){
		echo '<li><a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' .   $post["post_title"].'</a> </li> ';
	      }
           ?>
        </ul>
   	<h3>Archives</h3>
    	<ul>
           <!-- Show Archives by month -->
    	   <?php wp_get_archives('type=monthly'); ?>
    	</ul>
        <h3>Categories</h3>
        <ul>
            <!-- Show list of Categories -->
    	    <?php wp_list_categories('show_count=1&title_li='); ?>
        </ul>
    <?php endif; ?>
</div>

Next, functions.php

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s