<?php 
    /* get categories */
        $taxo = 'teams-categories';
        $_category = array();
        if(!isset($args['cat']) || $args['cat']==''){
            $terms = get_terms($taxo);
            foreach ($terms as $cat){
                $_category[] = $cat->term_id;
            }
        } else {
            $_category  = explode(',', $args['cat']);
        }
        $atts['categories'] = $_category;
        $pretty_rel_random = ' rel="prettyPhoto[rel-' . get_the_ID() . '-' . rand() . ']"'; //rel-'.rand();
?>
<div class="layout-team grid-team-layout2 filtrer-center cms-grid-wraper <?php echo esc_attr($atts['template']);?>" id="<?php echo esc_attr($atts['html_id']);?>">
    <?php if($atts['filter']=="true" and $atts['layout']=='masonry'):?>
        <div class="cms-grid-filter">
            <ul>
                <li><a class="active" href="#" data-group="all"><?php esc_html_e('All', "wp-yellow-hats"); ?></a></li>
                <?php foreach($atts['categories'] as $category):?>
                    <?php $term = get_term( $category, $taxo );?>
                    <li><a href="#" data-group="<?php echo esc_attr('category-'.$term->slug);?>">
                            <?php echo esc_html($term->name);?>
                        </a>
                    </li>
                <?php endforeach;?>
            </ul>
        </div>
    <?php endif;?>
    <div class="clearfix row <?php echo esc_attr($atts['grid_class']);?>">
        <?php
        $posts = $atts['posts'];
        $size = 'wp_yellow_hats_images-team';
        while($posts->have_posts()){
            $posts->the_post();
            $groups = array();
            $groups[] = '"all"';
            $team_meta = wp_yellow_hats_post_meta_data();
            $hide_load_more = isset( $atts['hide_load_more'] ) ? $atts['hide_load_more'] : '';
            foreach(cmsGetCategoriesByPostID(get_the_ID(),$taxo) as $category){
                $groups[] = '"category-'.$category->slug.'"';
            }
            ?>
            <div class="cms-grid-item cms-team-item <?php echo esc_attr($atts['item_class']);?>" data-groups='[<?php echo implode(',', $groups);?>]'>
                <div class="cms-grid-item-inner cms-team-item-inner row clearfix">
                    <div class="cms-team-image col-xs-12 col-sm-6 col-md-4 col-lg-4">
                        <a href="<?php the_permalink(); ?>">
                            <?php 
                                if(has_post_thumbnail() && !post_password_required() && !is_attachment() &&  wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), $size, false)):
                                    $class = ' has-thumbnail';
                                    $thumbnail_url = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), $size, false);
                                    $thumbnail = get_the_post_thumbnail(get_the_ID(),'wp_yellow_hats_images-team');
                                else:
                                    $class = ' no-image';
                                    $thumbnail_url[0] = get_template_directory_uri(). '/assets/images/no-image.jpg';
                                    $thumbnail = '<img src="'.esc_url(get_template_directory_uri(). '/assets/images/no-image-370x420.jpg').'" alt="'.get_the_title().'" />';
                                endif;
                                echo ''.$thumbnail.'';
                            ?>
                        </a>
                    </div>
                    <div class="cms-team-content col-xs-12 col-sm-6 col-md-8 col-lg-8">
                        <h3 class="cms-team-title"><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h3>
                        <div class="cms-team-position line-wrap">
                            <?php echo  esc_attr($team_meta->_cms_team_position); ?>
                            <div class="line-icon2"></div>
                        </div>
                        <div class="cms-team-desc"><?php echo substr(get_the_excerpt(), 0,200); ?>...</div>
                        <a class="cms-team-more" href="<?php the_permalink(); ?>"><i class="fa fa-plus"></i><?php esc_html_e('Read More', 'wp-yellow-hats'); ?></a>
                    </div>
                </div>
            </div>
            <?php
        }
        ?>
    </div>
    <?php if(empty($hide_load_more)) { ?>
        <div class="cms_pagination text-center"></div>
    <?php } ?>
</div>