<?php
/*
Template Name: Archives
*/

// Counts the posts, comments and categories
$numposts = $wpdb->get_var("SELECT COUNT(1) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type != 'page'");
if (0 < $numposts) $numposts = number_format($numposts); 

$numcomms = $wpdb->get_var("SELECT COUNT(1) FROM $wpdb->comments WHERE comment_approved = '1'");
if (0 < $numcomms) $numcomms = number_format($numcomms);

$numcats = count(get_all_category_ids());


get_header(); 
while (have_posts()) : the_post(); 	
?>
      <div class="post" id="post-<?php the_ID(); ?>">	
        <div class="pagehead">
          <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title='<?php printf( __('Permanent Link to "%s"','WPCandyEx'), wp_specialchars(strip_tags(the_title('', '', false)),1) ); ?>'><?php the_title(); ?></a></h2>
        </div>
        <div class="entry">
          <p class="archivetext"><?php printf('目前本 Blog 有 %2$s 篇文章、%3$s 条评论和 %4$s 个分类。在这里您可以按时间和分类查找文章。如果您需要查找指定的内容，您可以使用右边的搜索功能。', get_bloginfo('name'), $numposts, $numcomms, $numcats); ?></p>
       
          <?php if (function_exists('wp_tag_cloud')) { ?>

          <div class="archives">
            <h3><?php _e('Tag Cloud','WPCandyEx'); ?></h3>
            <div id="tag-cloud">
            <?php wp_tag_cloud(); ?>
            </div>
          </div>
          <?php } ?>

          <div class="archives">
            <h3><?php _e('Browse by Month','WPCandyEx'); ?></h3>
            <ul class="archivelist bydate clearfix">
              <?php wp_get_archives('show_post_count=1'); ?>
            </ul>
          </div>

          <div class="archives">
            <h3><?php _e('Browse by Category','WPCandyEx'); ?></h3>
            <ul class="archivelist bycat clearfix">
              <?php wp_list_cats('hierarchical=0&optioncount=1'); ?>
            </ul>
          </div>             
        </div>			
      </div>
<?php 
endwhile; 
?>
    </div><!-- /main -->
<?php 
get_sidebar(); 
get_footer(); 
?>