<?php
/* Template Name: Blog */
get_header();
?>
<div class="container">
    <div class="row">
        <div class="col-lg-12 accroche">
            <h1><?php echo get_field('titre_de_la_page');?></h1>
        </div>
    </div>
    <div class="row">
        <?php
        $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
        $args = array (
            'post_type' => 'post',
            'order' => 'DESC',
            'cat' => -7,
            'posts_per_page' => 6,
            'category__not_in' => 1,
            'paged' => $paged
            );
        $query = new WP_Query( $args );
        $i = 0;

        if ($query->have_posts()):
            while ( $query->have_posts() ) : $query->the_post();
                //echo $i;
                $cats = get_the_category();
                $wpseo_primary_term = new WPSEO_Primary_Term( 'category', get_the_id() );
				$wpseo_primary_term = $wpseo_primary_term->get_primary_term();
				$term = get_term( $wpseo_primary_term );
				//print_r($term);
                //foreach ($cats as $cat) {
                    if($term->slug == 'web-design')
                    {
                        $classColor = 'agenceWeb';
                    }elseif($term->slug == 'graphisme')
                    {
                        $classColor = 'studioGraphique';
                    }elseif($term->slug == 'video')
                    {
                        $classColor = 'productionAudiovisuelle';
                    }elseif($term->slug == 'e-marketing')
                    {
                        $classColor = 'inboundMarketing';
                    }elseif($term->slug == 'formation')
                    {
                        $classColor = 'formationSurMesure';
                    }
                //}

                //print_r($cat);

                if($i == 0):
                    echo ('<div class="col-lg-1 ' . $classColor .'">');
                elseif($i == 1):
                    echo ('<div class="offset-lg-4 col-lg-1 ' . $classColor .'">');
                elseif($i == 2):
                    echo ('<div class="offset-lg-8 col-lg-1 ' . $classColor .'">');
                elseif($i == 3):
                    echo ('<div class="offset-lg-11 col-lg-1 ' . $classColor .'">');
                elseif($i == 4):
                    echo ('<div class="offset-lg-8 col-lg-1 ' . $classColor .'">');
                elseif($i == 5):
                    echo ('<div class="offset-lg-4 col-lg-1 ' . $classColor .'">');
                endif;
            ?>
                <div class="circle"></div>
                </div>
                <div class="col-12">
                    <div class="row hoverbargeneral">
                        <div class="col-lg-4 <?php echo $classColor;?> hoverbar">
                            <a href="<?php the_permalink();?>"><h2><?php the_title();?></h2></a>
                            <div class="resume">
                                <a href="<?php the_permalink();?>"><p><?php the_excerpt();?></p></a>
                            </div>
                        </div>
                        <div class="col-lg-8 imgArticle <?php echo $classColor;?>">
                            <a href="<?php the_permalink(); ?>">
                            <?php the_post_thumbnail();?>
                            </a>
                            <div class="barHover"></div>
                        </div>
                    </div>
                </div>
                <?php
                $i++;
            endwhile;
            ?>
        <div class="col-lg-12">
        <?php
        //if (function_exists(custom_pagination)) {
            custom_pagination($query->max_num_pages,"",$paged);
        //}
        ?>
        </div>
         <?php endif; ?>
    </div>
    <div class="col-12">
    <div class="circleEnd"></div>
    </div>
</div>
<?php get_footer();?>
