<?php
/*
Template Name: Archives
*/

get_header(); ?>

	<div id="body">	
		
		<h3 class="bcrumb">
			<?php gabfire_breadcrumb(); ?>
		</h3>
		
		<div id="main_content">		
				<div id="post-<?php the_ID(); ?>" <?php post_class('post'); ?>>
					<div class="top"></div>
					<div class="body">
						<div class="head">
							<?php if (have_posts()) : while (have_posts()) : the_post(); ?>	
							<h1 class="entry_title"><?php the_title(); ?></h1>
							<?php edit_post_link(__('Edit','gabfire'),'',''); ?>
							<?php endwhile; endif; ?>
						</div><!-- /head -->
						<div class="entry">
							<?php
							
							the_content();
							
							// Display pagination
							gabfire_postpagination();
												
						   // This is where loop for archives list starts
							$cats = get_categories();
							foreach ($cats as $cat) {
							query_posts('cat='.$cat->cat_ID);
							?>
								<div class="widget">
								<h4><?php echo $cat->cat_name; ?></h4>
								<ul>	
									<?php while (have_posts()) : the_post(); ?>
									<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a> - (<?php echo $post->comment_count ?>)</li>
									<?php endwhile;  ?>
								</ul>
								</div>
							<?php }
							edit_post_link(__('Edit','gabfire'),'<p>','</p>'); 
							?>
						</div><!-- /entry -->
					</div><!-- /body -->
					<div class="bot"></div>
					
				</div><!-- /post -->

		</div><!-- /main_content -->
			
		<aside id="sidebar">
			<?php get_sidebar(); ?> 
		</aside>
	</div><!-- /body -->
<?php get_footer(); ?>