<?php
    $cont = 1;
    $args = array(
        'post_type' => 'post',
        'post_status' => 'publish',
        'posts_per_page' => 12,
        'meta_key'       => 'post_views_count',
        'orderby'        => 'meta_value_num date',
        'date_query' => array(
            array(
                'after' => '1 week ago'
            )
        )
    );
        // The Query
        $the_query = new WP_Query( $args );
        
        // The Loop
        if ( $the_query->have_posts() ):
    ?>
        <section id="mostPopular">
            <header class="container"><h2 class="sectiontitle">Most Popular</h2></header>
            <div class="container content-mostPopular">
                <?php	
                    while ( $the_query->have_posts() ) {
                        $the_query->the_post();
                        $category = get_the_category(); 
                        $terms = get_the_terms( $post->ID, 'countries' );
                        $odd = ($cont%2 != 0 )? 'odd' : '';
                        $large = array(3,5,7,12);
                        $size = (in_array($cont, $large))? 'large' : 'medium';
                        $size2 = (in_array($cont, $large))? '-large' : '';
                        $third = ($cont%3 == 0 )? 'third' : '';
                        $mobile = ($cont > 6 )? 'cardarticle-mobile' : '';    
                ?>
                    <article class="component-cardarticle  link-cat-<?php echo $category[0]->slug; ?> <?php echo $size; ?> cardarticle-<?php echo $cont; ?> <?php echo $odd; ?> <?php echo $third; ?> <?php echo $mobile; ?>">
                        <a href="<?php the_permalink(); ?>">
                            <div class="component-card medium bg-cat-<?php echo $category[0]->slug; ?>">
                                <?php if(has_post_thumbnail()): ?>
                                    <?php the_post_thumbnail( 'thumb-post-card'.$size2 ); ?>
                                <?php endif; ?>
                            </div>
                            <header>
                                <div class="component-dados">
                                    <span class="category"><?php echo $category[0]->cat_name; ?> <span></span></span>
                                    <span class="local"><?php echo $terms[0]->name; ?> <span></span></span>
                                    <span class="data"><?php the_time('M'); ?>  <?php the_time('j'); ?> ,  <?php the_time('Y'); ?></span> 
                                </div>
                                <h3 class="h4"><?php echo countText(get_the_title(), 66); ?></h3>
                                <?php //echo getPostViews(get_the_ID()); ?>
                            </header>
                        </a>
                    </article>
                    <?php if($cont == 5): ?>
                        <!-- <div class="component-publi medium  cardarticle-6 third">
                            <div style="width:250px; height:250px;background-color:#EF1366"></div>
                        </div> -->

                        <a href="#" class="bt-seeMore hideDesktop"><span>See More</span></a>
                    <?php //$cont++; elseif($cont == 9): ?>
                        <!-- <div class="component-publi medium cardarticle-10 cardarticle-mobile">
                            <div style="width:250px; height:250px;background-color:#fbfbfd"></div>
                        </div> -->
                    <?php //$cont++; 
                    endif; ?>

            
                    
                <?php $cont++;	} ?>
            </div>
        </section><!-- Most Popular -->
<?php 
    endif;
    /* Restore original Post Data */
    wp_reset_postdata();
?>