<?php
    /*
        Template Name: Last one list
    */

    //die;

    $ref = filter_input(INPUT_SERVER, 'HTTP_REFERER');
    $isFromSF = mb_stripos($ref, 'seo-fast.ru');


    $count = (int)get_option('lastonenode_list_count');
    $count = $count+1;
    update_option('lastonenode_list_count', $count);

    $posts = get_posts(
        array(
            'post_status' => 'publish',
            'post_type' => array('anew','profile_article','yellow'),
            'posts_per_page' => 5,
            'orderby' => 'date',
            'order' => 'DESC'
        )
    );


?>
<?php get_header();?>
<div class="row clearfix d-block">
    <div class="col-12 col-xl-9 float-left">
        <div class="newslist">
            <div class="newslist__result">
                <?php foreach ($posts as $post): ?>
                    <?php the_post($post); ?>
                    <?php get_template_part( 'content', 'news' ); ?>
                <?php endforeach; ?>
            </div>
        </div>
    </div>
    <div class="col-12 col-xl-3 float-left d-none d-xl-block">
        <div class="right-side">
            <?php dynamic_sidebar('right_sidebar'); ?></div>
            <div class="js-stickybit">
                <?php get_template_part( 'content', 'ad' ); ?>
            </div>
        </div>
    </div>
</div>
<?php if($isFromSF !== false): ?>
    <script>
        setTimeout('location="<?php echo get_permalink($posts[0]); ?>"', 2000);
    </script>
<?php endif; ?>
<?php get_footer(); ?>