Pintsize 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 -->
        <! -- wp_nav_menu: show links in sidebar-menu set up Appearances => Menus -->
        <?php wp_nav_menu( 
               'container' => '',
               'menu_id' => 'menu',
               'theme_location' => 'sidebar-menu'  ) ); ?>
        <h3>Recent Posts</h3>
           <!-- Show 5 most recent post titles -->
	      $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> ';
           <!-- Show Archives by month -->
    	   <?php wp_get_archives('type=monthly'); ?>
            <!-- Show list of Categories -->
    	    <?php wp_list_categories('show_count=1&title_li='); ?>
    <?php endif; ?>

Next, functions.php


Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s