<?php
/*
  Template Name: Blog Page
 */
?>
<?php get_header(); ?>
<!--Start Contetn wrapper-->
<div class="grid_24 content_wrapper">
    <div class="grid_15 alpha">
        <!--Start side content-->
        <div class="side_content">
            <?php
            //Protect against arbitrary paged values
            $paged = ( get_query_var('paged') ) ? absint(get_query_var('paged')) : 1;

            $args = array(
                'posts_per_page' => get_option('posts_per_page'),
                'post_type' => 'post',
                'paged' => $paged,
            );

            $the_query = new WP_Query($args);
            ?>   

            <!-- Start the Loop. -->
            <?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
                    <!--Start Post-->
                    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                        <h1 class="post_title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to ', 'themia-lite') . the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
                        <ul class="post_info">
                            <li class="postedon"><?php _e('Posted on', 'themia-lite'); ?>
                                <?php the_date(); ?>
                            </li>
                            <li class="postedin"><?php _e('in', 'themia-lite'); ?>
                                <?php the_category(', '); ?>
                            </li>
                            <li class="postedby"><?php _e('by', 'themia-lite'); ?>
                                <?php the_author_posts_link(); ?>
                            </li>
                        </ul>
                        <hr/>
                        <?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail())) { ?>
                            <a href="<?php the_permalink(); ?>">
                                <?php the_post_thumbnail('post_thumbnail', array('class' => 'postimg')); ?>
                            </a>
                            <?php
                        } else {
                            ?>
                            <a href="<?php the_permalink(); ?>"> <?php echo inkthemes_main_image(); ?> </a>
                            <?php
                        }
                        ?>
                        <?php the_excerpt(); ?>
                        <a href="<?php the_permalink(); ?>" class="continue"><?php _e('Continue reading...', 'themia-lite'); ?></a> </div>
                    <div class="shadow"> </div>
                    <!--End Post-->
                    <?php
                endwhile;
            else:
                ?>
                <div class="post">
                    <p>
                        <?php _e('Sorry, no posts matched your criteria.', 'themia-lite'); ?>
                    </p>
                </div>
            <?php endif; ?>

            <div class='wp-pagenavi'>
                <?php
                echo paginate_links(array(
                    'current' => max(1, get_query_var('paged')),
                    'total' => $the_query->max_num_pages
                ));
                ?>
            </div>
        </div>
        <!--End side content-->
    </div>
    <?php get_sidebar(); ?>
</div>
<!--End Content wrapper-->
<div class="clear"></div>
</div>
<?php get_footer(); ?>
