<?php
/* Template Name: Timeline */
get_header(); ?>

<article class="article-container" itemscope itemtype="http://schema.org/Article" role="main">
    <div class="row-fluid">
        
        <?php $get_meta = get_post_custom($post->ID); ?>
        
        <div class="article-content">
            <?php if ( !is_front_page() ){ ?>
                <header>
                    <?php serpentsoft_single_breadcrumb(); ?>

                    <h1 itemprop="headline"><?php the_title(); ?></h1>

                    <?php serpentsoft_single_meta_info(); ?>

                </header>
            <?php } ?>

            <span class="clearfix"></span>

            <div class="post-entry" itemprop="articleBody">
                <?php the_content(); ?>
            </div>
            
            <div class="timeline-page">    
                <?php $qry_Years = $wpdb->get_results( "SELECT COUNT(ID) AS NumOfPosts, YEAR(post_date) AS YearPosts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date DESC" ); ?>
                
                <?php if($qry_Years): ?>
                <?php foreach($qry_Years as $year): ?>
                    <div class="row-fluid">
                        <div><h2><?php echo $year->YearPosts; ?> (<?php echo $year->NumOfPosts; ?> Posts)</h2></div>
                        <?php $qry_PostsPerYear = new WP_Query('year=' . $year->YearPosts . '&posts_per_page=50'); ?>
                        <dl class="dl-horizontal">
                            <?php while ($qry_PostsPerYear->have_posts()): $qry_PostsPerYear->the_post(); ?>
                                <dt><span class="badge"><?php the_time('j'); ?></span><?php the_time('F'); ?></dt>
                                <dd><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></dd>
                            <?php endwhile; ?>
                        </dl>
                    </div>
                <?php endforeach; //$qry_Years Query ?>
                <?php endif; ?>
            </div>

            
            
            <div class="clearfix"></div>

            <?php serpentsoft_post_social_share_buttons(); ?>
        </div>
        
        <!-- Article Footer Start from author bio to comments box  -->
        <footer>

            <?php wp_reset_query(); ?>
            
            <!-- Members Comments -->
            <?php serpentsoft_comments_box(); ?>

        </footer>

    </div><!-- row-fluid -->
</article><!-- article-container -->

<?php get_footer(); ?>