<?php if (!defined('ABSPATH')) die('No direct access allowed'); ?>
<?php
//blog layout
wp_reset_query();

$args = array(
    'orderby' => $orderby,
    'order' => $order,
    'post_status' => array('publish')
);

$offset = 0;
if (isset($_GET['offset'])) {
    $offset = (int) $_GET['offset'];
    $args['offset'] = $offset;
}

if (!empty($posts_per_page)) {
    $args['posts_per_page'] = $posts_per_page;
}

if ((int) $category > 0) {
    $args['cat'] = $category;
}

if (!empty($posts)) {
    $posts = explode(',', $posts);
    $args['post__in'] = $posts;
}

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args['paged'] = $paged;


global $wp_query;
$original_query = $wp_query;
$wp_query = null;
$wp_query = new WP_Query($args);
global $post;
?>

<?php if (!empty($title)): ?>
    <h3 class="widget-title"><?php echo $title; ?></h3>
<?php endif; ?>

<?php if ($blog_view == "default"){ ?>

    <?php get_template_part('content', null); ?>

<?php } else{ ?>	

    <div class="alternate">

        <ul>

            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

                    <li id="post-<?php the_ID(); ?>">

                        <h6 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6>

                        <?php if ($show_image): ?>
                            <?php if (has_post_thumbnail()): ?>

                                <div class="bordered alignleft">
                                    <figure class="add-border">
                                        <a class="single-image" href="<?php the_permalink(); ?>">
                                            <img src="<?php echo ThemeMakersHelper::get_post_featured_image($post->ID, 74, true, 64); ?>" alt="<?php the_title(); ?>" />
                                        </a>
                                    </figure>
                                </div><!--/ .bordered-->

                            <?php endif; ?>
                        <?php endif; ?>        

                        <?php if ($_REQUEST['show_full_content']) : ?>
                            <?php the_content(); ?>
                        <?php else: ?>

                            <?php
                            if ($_REQUEST['excerpt_symbols_count']) {
                                if (empty($post->post_excerpt)) {
                                    echo substr($post->post_content, 0, $_REQUEST['excerpt_symbols_count']) . " ...";
                                } else {
                                    echo substr($post->post_excerpt, 0, $_REQUEST['excerpt_symbols_count']) . " ...";
                                }
                            } else {
                                echo $post->post_excerpt;
                            }
                            ?>

                        <?php endif; ?>

                    </li>

                    <?php
                endwhile;

            else:
                get_template_part('content', 'nothingfound');
            endif;
            

         ?>	

    </ul>

</div><!--/ .alternate-->	

<?php }; ?>

<?php
if ($show_pagination) {
    get_template_part('content', 'pagenavi');
}
//*****
$wp_query = null;
$wp_query = $original_query;
wp_reset_postdata();
