Improved sidebar: categories above archive, and don't display if only 'uncategorised'
authorLaury GvR <laury@gaslightmedia.com>
Thu, 13 Aug 2015 18:45:01 +0000 (14:45 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Thu, 13 Aug 2015 18:45:01 +0000 (14:45 -0400)
parts/blog-sidebar-r.php

index c6cf234..f40beca 100644 (file)
                         }
                 ?>
                 </ul>
-                <p>Archive</p>
-                <ul><?php wp_get_archives( array( 'type' => 'monthly', 'limit' => 12 ) ); ?></ul>
-                <p>Categories</p>
-                <ul>
                     <?php
                     $args = array(
                     'orderby' => 'name',
-                    'order' => 'ASC'
+                    'order' => 'ASC',
+                    'exclude' => get_category_by_slug('uncategorized')->term_id
                     );
-                  $categories = get_categories($args);
-                    foreach($categories as $category) {
-                      echo '<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </li> ';  }
+                    $categories = get_categories($args);
+                    if (count($categories) > 1) {
+                        echo '<p>Categories</p>';
+                        echo '<ul>';
+                        foreach($categories as $category) {
+                            echo '<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </li> ';
+                        }
+                        echo '</ul>';
+                    }
                     ?>
-                </ul>
+                
+                <p>Archive</p>
+                <ul><?php wp_get_archives( array( 'type' => 'monthly', 'limit' => 12 ) ); ?></ul>
             </div>
         </div>
\ No newline at end of file